Skip to content

Commit 17059fd

Browse files
committed
One less call when dealing with lru cache
1 parent 6e5f4f7 commit 17059fd

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

src/utils/redis.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -104,9 +104,10 @@ if (config.redis?.enabled) {
104104
const createKeyName = (key: RedisCommandArgument) => (key + (config.redis.useCompression ? ".c" : "")) as RedisCommandArgument;
105105

106106
exportClient.getWithCache = (key) => {
107-
if (cache && cacheClient && cache.has(key)) {
107+
const cachedItem = cache && cacheClient && cache.get(key);
108+
if (cachedItem != null) {
108109
memoryCacheHits++;
109-
return Promise.resolve(cache.get(key));
110+
return Promise.resolve(cachedItem);
110111
} else if (shouldClientCacheKey(key)) {
111112
memoryCacheMisses++;
112113
}

0 commit comments

Comments
 (0)