Merged in feat/redis-api-send-logs (pull request #2290)

feature: send logs to Sentry for Redis-Api

* feature: send logs to Sentry for Redis-Api


Approved-by: Linus Flood
This commit is contained in:
Joakim Jäderberg
2025-06-19 08:28:53 +00:00
parent 46e7f33ab6
commit 3af994b0a9
5 changed files with 65 additions and 12 deletions
+15 -8
View File
@@ -73,14 +73,21 @@ export const cacheRoutes = new Elysia({ prefix: "/cache" })
"/",
async ({ query: { key, fuzzy } }) => {
key = validateKey(key);
cacheRouteLogger.debug(
`DELETE /cache ${key} ${fuzzy ? "fuzzy" : ""}`,
);
const deletedKeys: number = fuzzy
? await deleteWithPattern(`*${key}*`)
: await redis.del(key);
cacheRouteLogger.info(`Deleted ${deletedKeys} keys for '${key}'`);
const keyToDelete = fuzzy ? `*${key}*` : key;
cacheRouteLogger.debug(`DELETE /cache ${keyToDelete}`);
const now = performance.now();
const deletedKeys: number = fuzzy
? await deleteWithPattern(keyToDelete)
: await redis.del(keyToDelete);
const elapsed = performance.now() - now;
cacheRouteLogger.info(
`Deleted ${deletedKeys} keys for '${keyToDelete}' in ${elapsed}ms`,
{ fuzzy, deletedKeys, keyToDelete, elapsed },
);
return { deletedKeys };
},
{
@@ -133,7 +140,7 @@ async function deleteWithPattern(pattern: string) {
const deleteCount = await redis.del(foundKeys);
cacheRouteLogger.info(`Deleted ${deleteCount} keys in this batch.`);
cacheRouteLogger.debug(`Deleted ${deleteCount} keys in this batch.`);
totalDeleteCount += deleteCount;
} while (cursor !== "0");