feat: 添加随机缓存时间支持并延长默认缓存时间
当请求参数包含random时,将缓存时间设置为5秒,否则默认延长至7天
This commit is contained in:
3
index.js
3
index.js
@@ -560,11 +560,12 @@ fastify.get('/*', async (request, reply) => {
|
|||||||
|
|
||||||
// 获取nocache 参数
|
// 获取nocache 参数
|
||||||
const nocache = request.query.nocache ? true : false;
|
const nocache = request.query.nocache ? true : false;
|
||||||
|
const random = request.query.random ? true : false;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const key = getTokenKey(token);
|
const key = getTokenKey(token);
|
||||||
const metaPath = getMetaPath(key);
|
const metaPath = getMetaPath(key);
|
||||||
const ONE_DAY_MS = 24 * 60 * 60 * 1000;
|
const ONE_DAY_MS = random ? 5 * 1000 : 86400 * 7 * 1000;
|
||||||
let apiData = null;
|
let apiData = null;
|
||||||
if (fs.existsSync(metaPath) && !nocache) {
|
if (fs.existsSync(metaPath) && !nocache) {
|
||||||
try {
|
try {
|
||||||
|
|||||||
Reference in New Issue
Block a user