Skip to content

Commit 8c98f39

Browse files
committed
feat: 支持订阅/文件级别的自定义缓存时长
1 parent 78c7b62 commit 8c98f39

3 files changed

Lines changed: 23 additions & 4 deletions

File tree

backend/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "sub-store",
3-
"version": "2.21.86",
3+
"version": "2.21.87",
44
"description": "Advanced Subscription Manager for QX, Loon, Surge, Stash and Shadowrocket.",
55
"main": "src/main.js",
66
"scripts": {

backend/src/utils/download.js

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -304,7 +304,13 @@ export default async function download(
304304
if (headers) {
305305
const flowInfo = getFlowField(headers);
306306
if (flowInfo) {
307-
headersResourceCache.set(id, flowInfo);
307+
headersResourceCache.set(
308+
id,
309+
flowInfo,
310+
$arguments?.headersCacheTtl
311+
? $arguments?.headersCacheTtl * 1000
312+
: undefined,
313+
);
308314
}
309315
}
310316
if (body.replace(/\s/g, '').length === 0)
@@ -345,7 +351,14 @@ export default async function download(
345351
}
346352
}
347353
if (shouldCache) {
348-
resourceCache.set(id, body);
354+
console.log($arguments);
355+
resourceCache.set(
356+
id,
357+
body,
358+
$arguments?.cacheTtl
359+
? $arguments?.cacheTtl * 1000
360+
: undefined,
361+
);
349362
if (customCacheKey) {
350363
$.info(
351364
`URL ${url}\n写入自定义缓存 ${$arguments?.cacheKey}`,

backend/src/utils/flow.js

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -226,7 +226,13 @@ export async function getFlowHeaders(
226226
flowInfo = flowInfo.trim();
227227
}
228228
if (flowInfo) {
229-
headersResourceCache.set(id, flowInfo);
229+
headersResourceCache.set(
230+
id,
231+
flowInfo,
232+
$arguments?.headersCacheTtl
233+
? $arguments?.headersCacheTtl * 1000
234+
: undefined,
235+
);
230236
}
231237
}
232238

0 commit comments

Comments
 (0)