mirror of
https://github.com/DIYgod/RSSHub.git
synced 2026-10-17 05:11:57 +08:00
revert: "perf: use only one WASM alloc for xxhash"
This reverts commit 01ecdd48d0.
This commit is contained in:
@@ -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);
|
||||
|
||||
|
||||
@@ -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);
|
||||
|
||||
|
||||
@@ -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 () => {
|
||||
|
||||
Reference in New Issue
Block a user