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:
Luke Hagar
2025-10-21 12:13:28 -05:00
parent c88f419b11
commit 9fda0058ea
2 changed files with 2 additions and 9 deletions

View File

@@ -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) };
}

View File

@@ -452,8 +452,4 @@ export async function invalidateSearchCache() {
// This would need to be implemented with pattern matching
// For now, we'll just clear the package count cache
await cache.del(CacheManager.getPackageCountKey());
}
export async function clearAllCache() {
await cache.flush();
}
}