mirror of
https://github.com/DIYgod/RSSHub.git
synced 2025-12-09 06:30:40 +08:00
feat: support no refresh cache
This commit is contained in:
@@ -34,10 +34,10 @@ module.exports = function(app, options = {}) {
|
||||
});
|
||||
|
||||
app.context.cache = {
|
||||
get: async (key) => {
|
||||
get: async (key, refresh = true) => {
|
||||
if (key && available) {
|
||||
let value = await redisClient.get(key);
|
||||
if (value) {
|
||||
if (value && refresh) {
|
||||
redisClient.expire(key, config.cache.contentExpire);
|
||||
value = value + '';
|
||||
}
|
||||
@@ -81,16 +81,16 @@ module.exports = function(app, options = {}) {
|
||||
});
|
||||
|
||||
app.context.cache = {
|
||||
get: (key) => {
|
||||
get: (key, refresh = true) => {
|
||||
if (key && available) {
|
||||
let value = routeCache.get(key);
|
||||
let value = (refresh ? routeCache : pageCache).get(key);
|
||||
if (value) {
|
||||
value = value + '';
|
||||
}
|
||||
return value;
|
||||
}
|
||||
},
|
||||
set: (key, value, maxAge = config.cache.contentExpire) => {
|
||||
set: (key, value, maxAge = config.cache.contentExpire, refresh = true) => {
|
||||
if (!value || value === 'undefined') {
|
||||
value = '';
|
||||
}
|
||||
@@ -98,7 +98,7 @@ module.exports = function(app, options = {}) {
|
||||
value = JSON.stringify(value);
|
||||
}
|
||||
if (key && available) {
|
||||
return routeCache.set(key, value, maxAge * 1000);
|
||||
return (refresh ? routeCache : pageCache).set(key, value, maxAge * 1000);
|
||||
}
|
||||
},
|
||||
client: [pageCache, routeCache],
|
||||
|
||||
Reference in New Issue
Block a user