mirror of
https://github.com/DIYgod/RSSHub.git
synced 2026-08-29 01:53:47 +08:00
fix(core/cache): update cache key generation to include query limit (#17674)
This commit is contained in:
@@ -8,7 +8,7 @@ import { Data } from '@/types';
|
||||
|
||||
const bypassList = new Set(['/', '/robots.txt', '/logo.png', '/favicon.ico']);
|
||||
// only give cache string, as the `!` condition tricky
|
||||
// md5 is used to shrink key size
|
||||
// XXH64 is used to shrink key size
|
||||
// plz, write these tips in comments!
|
||||
const middleware: MiddlewareHandler = async (ctx, next) => {
|
||||
if (!cacheModule.status.available || bypassList.has(ctx.req.path)) {
|
||||
@@ -16,9 +16,11 @@ const middleware: MiddlewareHandler = async (ctx, next) => {
|
||||
return;
|
||||
}
|
||||
|
||||
const requestPath = ctx.req.path;
|
||||
const limit = ctx.req.query('limit') ? `:${ctx.req.query('limit')}` : '';
|
||||
const { h64ToString } = await xxhash();
|
||||
const key = 'rsshub:koa-redis-cache:' + h64ToString(ctx.req.path);
|
||||
const controlKey = 'rsshub:path-requested:' + h64ToString(ctx.req.path);
|
||||
const key = 'rsshub:koa-redis-cache:' + h64ToString(requestPath + limit);
|
||||
const controlKey = 'rsshub:path-requested:' + h64ToString(requestPath + limit);
|
||||
|
||||
const isRequesting = await cacheModule.globalCache.get(controlKey);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user