mirror of
https://github.com/DIYgod/RSSHub.git
synced 2026-09-24 23:12:34 +08:00
fix(core): unnecessary redis io (#9875)
This commit is contained in:
Vendored
+7
-2
@@ -32,8 +32,10 @@ module.exports = {
|
||||
let [value, cacheTtl] = await redisClient.mget(key, cacheTtlKey);
|
||||
if (value && refresh) {
|
||||
if (!cacheTtl) {
|
||||
// if cacheTtl is not set, that means the cache expire time is contentExpire
|
||||
cacheTtl = config.cache.contentExpire;
|
||||
redisClient.set(cacheTtlKey, cacheTtl, 'EX', cacheTtl);
|
||||
// dont save cacheTtl to Redis, as it is the default value
|
||||
// redisClient.set(cacheTtlKey, cacheTtl, 'EX', cacheTtl);
|
||||
} else {
|
||||
redisClient.expire(cacheTtlKey, cacheTtl);
|
||||
}
|
||||
@@ -54,7 +56,10 @@ module.exports = {
|
||||
value = JSON.stringify(value);
|
||||
}
|
||||
if (key) {
|
||||
redisClient.set(getCacheTtlKey(key), maxAge, 'EX', maxAge);
|
||||
if (maxAge !== config.cache.contentExpire) {
|
||||
// Only set cacheTtlKey if maxAge !== contentExpire
|
||||
redisClient.set(getCacheTtlKey(key), maxAge, 'EX', maxAge);
|
||||
}
|
||||
return redisClient.set(key, value, 'EX', maxAge); // setMode: https://redis.io/commands/set
|
||||
}
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user