From 17059fdbe6d3e3f5c79ab9a79b656dc50ed10197 Mon Sep 17 00:00:00 2001 From: Ajay Date: Sat, 14 Sep 2024 17:52:50 -0400 Subject: [PATCH] One less call when dealing with lru cache --- src/utils/redis.ts | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/utils/redis.ts b/src/utils/redis.ts index d6da615..c555b7e 100644 --- a/src/utils/redis.ts +++ b/src/utils/redis.ts @@ -104,9 +104,10 @@ if (config.redis?.enabled) { const createKeyName = (key: RedisCommandArgument) => (key + (config.redis.useCompression ? ".c" : "")) as RedisCommandArgument; exportClient.getWithCache = (key) => { - if (cache && cacheClient && cache.has(key)) { + const cachedItem = cache && cacheClient && cache.get(key); + if (cachedItem != null) { memoryCacheHits++; - return Promise.resolve(cache.get(key)); + return Promise.resolve(cachedItem); } else if (shouldClientCacheKey(key)) { memoryCacheMisses++; }