refactor(backend): split log files into separate file

This commit is contained in:
2025-01-19 16:43:00 +01:00
parent e9cc56d7ee
commit f106460502
24 changed files with 155 additions and 113 deletions

View File

@@ -6,12 +6,18 @@ interface SetCacheOptions {
expires?: number; // Override expiration for individual cache entries
}
export const caches = new Map<
string,
{ info: () => { count: number; sizeInKB: number } }
>();
export function createCache<T>(
cacheName: string,
createOpts: CreateCacheOptions = {},
) {
const cache = new Map<string, { value: T; expiresAt?: number }>();
return {
const api = {
get(key: string): T | undefined {
const entry = cache.get(key);
if (!entry) return undefined;
@@ -86,4 +92,9 @@ export function createCache<T>(
return cache.size;
},
};
caches.set(cacheName, {
info: api.info.bind(api),
});
return api;
}