chore: bump lru-cache from 6.0.0 to 7.7.1 (#9339)
* feat(core): lru-cache v7 * chore: bump lru-cache to 7.7.1 * feat: configurable max
This commit is contained in:
@@ -388,6 +388,8 @@ RSSHub supports two caching methods: memory and redis
|
||||
|
||||
`REDIS_URL`: Redis target address (invalid when `CACHE_TYPE` is set to memory), default to `redis://localhost:6379/`
|
||||
|
||||
`MEMORY_MAX`: maximum number of cached items (invalid when `CACHE_TYPE` is set to redis), default to `256`
|
||||
|
||||
### Proxy Configurations
|
||||
|
||||
Partial routes have a strict anti-crawler policy, and can be configured to use proxy.
|
||||
|
||||
@@ -392,6 +392,8 @@ RSSHub 支持 `memory` 和 `redis` 两种缓存方式
|
||||
|
||||
`REDIS_URL`: Redis 连接地址(redis 缓存类型时有效),默认为 `redis://localhost:6379/`
|
||||
|
||||
`MEMORY_MAX`: 最大缓存数量(memory 缓存类型时有效),默认 `256`
|
||||
|
||||
### 代理配置
|
||||
|
||||
部分路由反爬严格,可以配置使用代理抓取。
|
||||
|
||||
@@ -49,6 +49,10 @@ const calculateValue = () => {
|
||||
routeExpire: parseInt(envs.CACHE_EXPIRE) || 5 * 60, // 路由缓存时间,单位为秒
|
||||
contentExpire: parseInt(envs.CACHE_CONTENT_EXPIRE) || 1 * 60 * 60, // 不变内容缓存时间,单位为秒
|
||||
},
|
||||
memory: {
|
||||
max: envs.MEMORY_MAX || Math.pow(2, 8), // The maximum number of items that remain in the cache. This must be a positive finite intger.
|
||||
// https://github.com/isaacs/node-lru-cache#options
|
||||
},
|
||||
redis: {
|
||||
url: envs.REDIS_URL || 'redis://localhost:6379/',
|
||||
},
|
||||
|
||||
Vendored
+1
-1
@@ -41,7 +41,7 @@ if (config.cache.type === 'redis') {
|
||||
value = JSON.stringify(value);
|
||||
}
|
||||
if (key) {
|
||||
return pageCache.set(key, value, maxAge * 1000);
|
||||
return pageCache.set(key, value, { ttl: maxAge * 1000 });
|
||||
}
|
||||
};
|
||||
} else {
|
||||
|
||||
Vendored
+5
-5
@@ -4,13 +4,13 @@ const config = require('@/config').value;
|
||||
const status = { available: false };
|
||||
|
||||
const pageCache = new Lru({
|
||||
maxAge: config.cache.routeExpire * 1000,
|
||||
max: Infinity,
|
||||
ttl: config.cache.routeExpire * 1000,
|
||||
max: config.memory.max,
|
||||
});
|
||||
|
||||
const routeCache = new Lru({
|
||||
maxAge: config.cache.routeExpire * 1000,
|
||||
max: Infinity,
|
||||
ttl: config.cache.routeExpire * 1000,
|
||||
max: config.memory.max,
|
||||
updateAgeOnGet: true,
|
||||
});
|
||||
|
||||
@@ -34,7 +34,7 @@ module.exports = {
|
||||
value = JSON.stringify(value);
|
||||
}
|
||||
if (key && status.available) {
|
||||
return (refresh ? routeCache : pageCache).set(key, value, maxAge * 1000);
|
||||
return (refresh ? routeCache : pageCache).set(key, value, { ttl: maxAge * 1000 });
|
||||
}
|
||||
},
|
||||
clients: { pageCache, routeCache },
|
||||
|
||||
+1
-1
@@ -110,7 +110,7 @@
|
||||
"koa-basic-auth": "4.0.0",
|
||||
"koa-favicon": "2.1.0",
|
||||
"koa-mount": "4.0.0",
|
||||
"lru-cache": "6.0.0",
|
||||
"lru-cache": "7.7.1",
|
||||
"lz-string": "1.4.4",
|
||||
"mailparser": "3.4.0",
|
||||
"markdown-it": "12.3.2",
|
||||
|
||||
@@ -9005,12 +9005,10 @@ lowercase-keys@^2.0.0:
|
||||
resolved "https://registry.yarnpkg.com/lowercase-keys/-/lowercase-keys-2.0.0.tgz#2603e78b7b4b0006cbca2fbcc8a3202558ac9479"
|
||||
integrity sha512-tqNXrS78oMOE73NMxK4EMLQsQowWf8jKooH9g7xPavRT706R6bkQJ6DY2Te7QukaZsulxa30wQ7bk0pm4XiHmA==
|
||||
|
||||
lru-cache@6.0.0, lru-cache@^6.0.0:
|
||||
version "6.0.0"
|
||||
resolved "https://registry.yarnpkg.com/lru-cache/-/lru-cache-6.0.0.tgz#6d6fe6570ebd96aaf90fcad1dafa3b2566db3a94"
|
||||
integrity sha512-Jo6dJ04CmSjuznwJSS3pUeWmd/H0ffTlkXXgwZi+eq1UCmqQwCh+eLsYOYCwY991i2Fah4h1BEMCx4qThGbsiA==
|
||||
dependencies:
|
||||
yallist "^4.0.0"
|
||||
lru-cache@7.7.1:
|
||||
version "7.7.1"
|
||||
resolved "https://registry.yarnpkg.com/lru-cache/-/lru-cache-7.7.1.tgz#03d2846b1ad2dcc7931a9340b8711d9798fcb0c6"
|
||||
integrity sha512-cRffBiTW8s73eH4aTXqBcTLU0xQnwGV3/imttRHGWCrbergmnK4D6JXQd8qin5z43HnDwRI+o7mVW0LEB+tpAw==
|
||||
|
||||
lru-cache@^4.0.1, lru-cache@^4.1.2:
|
||||
version "4.1.5"
|
||||
@@ -9027,6 +9025,13 @@ lru-cache@^5.1.1:
|
||||
dependencies:
|
||||
yallist "^3.0.2"
|
||||
|
||||
lru-cache@^6.0.0:
|
||||
version "6.0.0"
|
||||
resolved "https://registry.yarnpkg.com/lru-cache/-/lru-cache-6.0.0.tgz#6d6fe6570ebd96aaf90fcad1dafa3b2566db3a94"
|
||||
integrity sha512-Jo6dJ04CmSjuznwJSS3pUeWmd/H0ffTlkXXgwZi+eq1UCmqQwCh+eLsYOYCwY991i2Fah4h1BEMCx4qThGbsiA==
|
||||
dependencies:
|
||||
yallist "^4.0.0"
|
||||
|
||||
lru_map@^0.3.3:
|
||||
version "0.3.3"
|
||||
resolved "https://registry.yarnpkg.com/lru_map/-/lru_map-0.3.3.tgz#b5c8351b9464cbd750335a79650a0ec0e56118dd"
|
||||
|
||||
Reference in New Issue
Block a user