type CacheEntry = { value: T; expiresAt: number; }; export class MemoryCache { private readonly store = new Map>(); public get(key: string): T | undefined { const hit = this.store.get(key); if (!hit) { return undefined; } if (Date.now() >= hit.expiresAt) { this.store.delete(key); return undefined; } return hit.value as T; } public set(key: string, value: T, ttlMs: number): void { this.store.set(key, { value, expiresAt: Date.now() + ttlMs }); } }