Add to cache when calling set

This commit is contained in:
Ajay
2024-02-09 17:28:59 -05:00
parent 02a640d857
commit 9fa248037a

View File

@@ -152,6 +152,10 @@ if (config.redis?.enabled) {
return request; return request;
}; };
exportClient.setWithCache = (key, value, options) => { exportClient.setWithCache = (key, value, options) => {
if (cache) {
cache.set(key, value as string);
}
if (config.redis.useCompression) { if (config.redis.useCompression) {
return compress(Buffer.from(value as string, "utf-8")).then((compressed) => return compress(Buffer.from(value as string, "utf-8")).then((compressed) =>
exportClient.set(createKeyName(key), compressed.toString("base64"), options) exportClient.set(createKeyName(key), compressed.toString("base64"), options)
@@ -161,6 +165,10 @@ if (config.redis?.enabled) {
} }
}; };
exportClient.setExWithCache = (key, seconds, value) => { exportClient.setExWithCache = (key, seconds, value) => {
if (cache) {
cache.set(key, value as string);
}
if (config.redis.useCompression) { if (config.redis.useCompression) {
return compress(Buffer.from(value as string, "utf-8")).then((compressed) => return compress(Buffer.from(value as string, "utf-8")).then((compressed) =>
exportClient.setEx(createKeyName(key), seconds, compressed.toString("base64")) exportClient.setEx(createKeyName(key), seconds, compressed.toString("base64"))