export class CacheManager {
private cache: Map<string, { value: any; expiresAt: number | null }> = new Map();
get(key: string): any {
const entry = this.cache.get(key);
if (!entry) return undefined;
if (entry.expiresAt !== null && Date.now() > entry.expiresAt) {
this.cache.delete(key);
return undefined;
}
return entry.value;
}
set(key: string, value: any, ttlSeconds?: number): void {
const expiresAt = ttlSeconds ? Date.now() + ttlSeconds * 1000 : null;
this.cache.set(key, { value, expiresAt });
}
clear(): void {
this.cache.clear();
}
}