diff --git a/packages/core/src/caches/index.ts b/packages/core/src/caches/index.ts index b92c368a1..45531fc0a 100644 --- a/packages/core/src/caches/index.ts +++ b/packages/core/src/caches/index.ts @@ -90,6 +90,9 @@ export class RedisCache extends RedisCacheBase { this.client = createClient({ url: conditional(!yes(redisUrl) && redisUrl), socket: this.getSocketOptions(trySafe(() => new URL(redisUrl))), + // Azure redis has a 10 minutes idle timeout + // @see https://learn.microsoft.com/en-us/azure/azure-cache-for-redis/cache-best-practices-connection#idle-timeout + pingInterval: 8 * 60 * 1000, // 8 minutes }); this.client.on('error', (error) => { diff --git a/packages/core/src/caches/well-known.ts b/packages/core/src/caches/well-known.ts index 7b9f12f62..d3ba49981 100644 --- a/packages/core/src/caches/well-known.ts +++ b/packages/core/src/caches/well-known.ts @@ -89,15 +89,16 @@ export class WellKnownCache { /** * Get value from the inner cache store for the given type and key. - * Note: Format errors will be silently caught and result an `undefined` return. + * Note: Redis connection and format errors will be silently caught and result an `undefined` return. */ async get( type: Type, key: string ): Promise> { - const data = await this.cacheStore.get(this.cacheKey(type, key)); - - return trySafe(() => getValueGuard(type).parse(JSON.parse(data ?? ''))); + return trySafe(async () => { + const data = await this.cacheStore.get(this.cacheKey(type, key)); + return getValueGuard(type).parse(JSON.parse(data ?? '')); + }); } /**