File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -102,7 +102,8 @@ CSDN:`https://stats.justsong.cn/api/csdn?id=vczh`
1021021 . ` BILIBILI_SESSDATA ` :B 站的 ` SESSDATA ` Cookie,用以抓取 B 站数据,注意这个 Cookie 半年过期一次,届时需要重新设置 & 部署。
1031032 . ` GITHUB_TOKEN ` :GitHub Token,无任何权限的即可,用于抓取 GitHub 数据。
1041043 . ` CACHE_TIME ` :缓存时间,包括服务端缓存和客户端缓存,单位为秒,默认 ` 6000 ` ,即 100 分钟。
105- 4 . ` PORT ` :服务端口号,默认 ` 3000 ` 。
105+ 4 . ` MAX_CACHE_ITEMS ` :最大缓存数量,默认 ` 1024 ` ,缓存超出后将采取 LRU 策略进行淘汰。
106+ 5 . ` PORT ` :服务端口号,默认 ` 3000 ` 。
106107
107108### 部署到 Vercel
108109
Original file line number Diff line number Diff line change 11// https://github.com/isaacs/node-lru-cache
22const LRU = require ( 'lru-cache' ) ;
33
4- const cacheTime = process . env . CACHE_TIME || 100 * 60 ; // 100 min
4+ const cacheTime = process . env . CACHE_TIME || 100 * 60 ; // 100 min
5+ const maxCacheItems = process . env . MAX_CACHE_ITEMS || 1024 ;
56
67const options = {
7- max : 1000 ,
8+ max : maxCacheItems ,
89 // how long to live in ms
910 ttl : cacheTime * 1000 ,
1011 // return stale items before removing from cache?
1112 allowStale : true ,
1213 updateAgeOnGet : false ,
13- updateAgeOnHas : false
14+ updateAgeOnHas : false ,
1415} ;
1516
1617const cache = new LRU ( options ) ;
1718
1819module . exports = {
1920 cache,
20- cacheTime
21- } ;
21+ cacheTime,
22+ } ;
You can’t perform that action at this time.
0 commit comments