mirror of
https://github.com/ajayyy/SponsorBlockServer.git
synced 2025-12-06 11:36:58 +03:00
Add to cache when calling set
This commit is contained in:
@@ -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"))
|
||||||
|
|||||||
Reference in New Issue
Block a user