From ee7c8549ab39bcc8063cb7d6777366ddf8ffbb72 Mon Sep 17 00:00:00 2001 From: TonyRL Date: Wed, 8 Jul 2026 22:29:57 +0800 Subject: [PATCH] revert: "perf: use only one WASM alloc for xxhash" This reverts commit 01ecdd48d09a046dce05f440814dcbec0323a7de. --- lib/api/route/status.ts | 4 +--- lib/middleware/cache.ts | 4 +--- lib/routes/economist/espresso.ts | 4 +--- 3 files changed, 3 insertions(+), 9 deletions(-) diff --git a/lib/api/route/status.ts b/lib/api/route/status.ts index 0095a2ef44..f7b2e1ca0c 100644 --- a/lib/api/route/status.ts +++ b/lib/api/route/status.ts @@ -4,8 +4,6 @@ import xxhash from 'xxhash-wasm'; import cacheModule from '@/utils/cache/index'; -const xxhashPromise = xxhash(); - const QuerySchema = z.object({ requestPath: z.string().openapi({ param: { @@ -64,7 +62,7 @@ const handler: RouteHandler = async (ctx) => { } const { requestPath } = ctx.req.valid('query'); - const { h64ToString } = await xxhashPromise; + const { h64ToString } = await xxhash(); const key = 'rsshub:koa-redis-cache:' + h64ToString(requestPath + ':rss'); const cached = await cacheModule.globalCache.has(key); diff --git a/lib/middleware/cache.ts b/lib/middleware/cache.ts index 5acb0ef330..3deaa14da7 100644 --- a/lib/middleware/cache.ts +++ b/lib/middleware/cache.ts @@ -7,8 +7,6 @@ import type { Data } from '@/types'; import cacheModule from '@/utils/cache/index'; const bypassList = new Set(['/', '/robots.txt', '/logo.png', '/favicon.ico']); - -const xxhashPromise = xxhash(); // only give cache string, as the `!` condition tricky // XXH64 is used to shrink key size // plz, write these tips in comments! @@ -21,7 +19,7 @@ const middleware: MiddlewareHandler = async (ctx, next) => { const requestPath = ctx.req.path; const format = `:${ctx.req.query('format') || 'rss'}`; const limit = ctx.req.query('limit') ? `:${ctx.req.query('limit')}` : ''; - const { h64ToString } = await xxhashPromise; + const { h64ToString } = await xxhash(); const key = 'rsshub:koa-redis-cache:' + h64ToString(requestPath + format + limit); const controlKey = 'rsshub:path-requested:' + h64ToString(requestPath + format + limit); diff --git a/lib/routes/economist/espresso.ts b/lib/routes/economist/espresso.ts index fce8fb8910..bce577e324 100644 --- a/lib/routes/economist/espresso.ts +++ b/lib/routes/economist/espresso.ts @@ -11,8 +11,6 @@ import { parseDate } from '@/utils/parse-date'; const link = 'https://www.economist.com/the-world-in-brief'; -const xxhashPromise = xxhash(); - export const route: Route = { path: '/espresso', categories: ['traditional-media'], @@ -39,7 +37,7 @@ export const route: Route = { }; async function handler() { - const { h64ToString } = await xxhashPromise; + const { h64ToString } = await xxhash(); const nextData = await cache.tryGet( link, async () => {