From 9fa248037a43f9c5438f0a18d6afbd363e695d0a Mon Sep 17 00:00:00 2001 From: Ajay Date: Fri, 9 Feb 2024 17:28:59 -0500 Subject: [PATCH] Add to cache when calling set --- src/utils/redis.ts | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/utils/redis.ts b/src/utils/redis.ts index d794d50..a44244e 100644 --- a/src/utils/redis.ts +++ b/src/utils/redis.ts @@ -152,6 +152,10 @@ if (config.redis?.enabled) { return request; }; exportClient.setWithCache = (key, value, options) => { + if (cache) { + cache.set(key, value as string); + } + if (config.redis.useCompression) { return compress(Buffer.from(value as string, "utf-8")).then((compressed) => exportClient.set(createKeyName(key), compressed.toString("base64"), options) @@ -161,6 +165,10 @@ if (config.redis?.enabled) { } }; exportClient.setExWithCache = (key, seconds, value) => { + if (cache) { + cache.set(key, value as string); + } + if (config.redis.useCompression) { return compress(Buffer.from(value as string, "utf-8")).then((compressed) => exportClient.setEx(createKeyName(key), seconds, compressed.toString("base64"))