mirror of
https://github.com/LukeHagar/pypistats.dev.git
synced 2025-12-06 04:21:09 +00:00
Refactor Redis command execution in hooks.server.ts to use the send method for improved performance. Remove unused clearAllCache function from api.ts to clean up the codebase.
This commit is contained in:
@@ -59,10 +59,7 @@ async function consumeSlidingWindow(key: string, points: number, windowSeconds:
|
||||
redis.call('EXPIRE', key, windowStart + (60*60*24) == 0 and 60 or math.floor((now - windowStart)/1000) + 5)
|
||||
return count
|
||||
`;
|
||||
const count = (await client.eval(lua, {
|
||||
keys: [listKey],
|
||||
arguments: [String(now), String(windowStart), String(points), String(MAX_REQUESTS)]
|
||||
})) as number;
|
||||
const count = await client.send(lua, [listKey, String(now), String(windowStart), String(points), String(MAX_REQUESTS)]);
|
||||
return { allowed: count <= MAX_REQUESTS, remaining: Math.max(0, MAX_REQUESTS - count) };
|
||||
}
|
||||
|
||||
|
||||
@@ -453,7 +453,3 @@ export async function invalidateSearchCache() {
|
||||
// For now, we'll just clear the package count cache
|
||||
await cache.del(CacheManager.getPackageCountKey());
|
||||
}
|
||||
|
||||
export async function clearAllCache() {
|
||||
await cache.flush();
|
||||
}
|
||||
Reference in New Issue
Block a user