From 9afdcf82f26f6afa24a3e3c3e1076459361613f6 Mon Sep 17 00:00:00 2001 From: HarukaKishida Date: Fri, 21 Mar 2025 09:55:29 +0900 Subject: [PATCH] fix redis-cache.service and keyv/redis version --- apps/api/src/app/redis-cache/redis-cache.service.ts | 8 +++----- package.json | 2 +- 2 files changed, 4 insertions(+), 6 deletions(-) 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 24eeb659a..a720bd027 100644 --- a/apps/api/src/app/redis-cache/redis-cache.service.ts +++ b/apps/api/src/app/redis-cache/redis-cache.service.ts @@ -21,10 +21,9 @@ export class RedisCacheService { public async getKeys(aPrefix?: string): Promise { const prefix = aPrefix; const keyList = []; + this.cache.stores[0].iterator((key) => { - if (prefix && key.startsWith(prefix)) { - keyList.push(key); - } else if (!prefix) { + if ((prefix && key.startsWith(prefix)) || !prefix) { keyList.push(key); } }); @@ -58,9 +57,8 @@ export class RedisCacheService { public async isHealthy() { try { - const client = this.cache.stores[0]; const isHealthy = await Promise.race([ - client.ttl, + this.getKeys(), new Promise((_, reject) => setTimeout( () => reject(new Error('Redis health check timeout')), diff --git a/package.json b/package.json index c20e003cb..4ba67daba 100644 --- a/package.json +++ b/package.json @@ -76,7 +76,7 @@ "@dfinity/principal": "0.15.7", "@dinero.js/currencies": "2.0.0-alpha.8", "@internationalized/number": "3.6.0", - "@keyv/redis": "^4.2.0", + "@keyv/redis": "^4.3.1", "@nestjs/bull": "11.0.1", "@nestjs/cache-manager": "3.0.0", "@nestjs/common": "11.0.6",