diff --git a/apps/api/src/app/redis-cache/redis-cache.module.ts b/apps/api/src/app/redis-cache/redis-cache.module.ts index 31c93d067..72825fe6a 100644 --- a/apps/api/src/app/redis-cache/redis-cache.module.ts +++ b/apps/api/src/app/redis-cache/redis-cache.module.ts @@ -1,7 +1,7 @@ import { ConfigurationModule } from '@ghostfolio/api/services/configuration/configuration.module'; import { ConfigurationService } from '@ghostfolio/api/services/configuration/configuration.service'; -import KeyvRedis, { Keyv } from '@keyv/redis'; +import { createKeyv } from '@keyv/redis'; import { CacheModule } from '@nestjs/cache-manager'; import { Module } from '@nestjs/common'; @@ -10,7 +10,7 @@ import { RedisCacheService } from './redis-cache.service'; @Module({ exports: [RedisCacheService], imports: [ - CacheModule.registerAsync({ + CacheModule.registerAsync({ imports: [ConfigurationModule], inject: [ConfigurationService], useFactory: async (configurationService: ConfigurationService) => { @@ -19,14 +19,12 @@ import { RedisCacheService } from './redis-cache.service'; ); return { - store: new Keyv({ - store: new KeyvRedis( + stores: [ + createKeyv( `redis://${redisPassword ? `:${redisPassword}` : ''}@${configurationService.get('REDIS_HOST')}:${configurationService.get('REDIS_PORT')}/${configurationService.get('REDIS_DB')}` - ), - ttl: configurationService.get('CACHE_TTL'), - useKeyPrefix: false - }) - } as Keyv; + ) + ] + }; } }), ConfigurationModule diff --git a/apps/api/src/app/redis-cache/redis-cache.service.ts b/apps/api/src/app/redis-cache/redis-cache.service.ts index 66c55f53b..0ab478a3e 100644 --- a/apps/api/src/app/redis-cache/redis-cache.service.ts +++ b/apps/api/src/app/redis-cache/redis-cache.service.ts @@ -22,11 +22,11 @@ export class RedisCacheService { const keys = []; const prefix = aPrefix; - this.cache.stores[0].iterator((key) => { + for await (const [key] of this.cache.stores[0].iterator({})) { if ((prefix && key.startsWith(prefix)) || !prefix) { keys.push(key); } - }); + } return keys; }