revert: "perf: use only one WASM alloc for xxhash"

This reverts commit 01ecdd48d0.
This commit is contained in:
TonyRL
2026-07-08 22:29:57 +08:00
parent 6b242a1e8e
commit ee7c8549ab
3 changed files with 3 additions and 9 deletions
+1 -3
View File
@@ -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<typeof route> = 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);
+1 -3
View File
@@ -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);
+1 -3
View File
@@ -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 () => {