feat: 添加随机缓存时间支持并延长默认缓存时间

当请求参数包含random时,将缓存时间设置为5秒,否则默认延长至7天
This commit is contained in:
2026-01-08 08:30:11 +08:00
parent c4561ab567
commit ea22b11610

View File

@@ -560,11 +560,12 @@ fastify.get('/*', async (request, reply) => {
// 获取nocache 参数
const nocache = request.query.nocache ? true : false;
const random = request.query.random ? true : false;
try {
const key = getTokenKey(token);
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;
if (fs.existsSync(metaPath) && !nocache) {
try {