ATProto social network
Something went wrong. Try again.
12345678910111213141516171819202122232425262728293031323334353637import { LRUCache } from 'lru-cache';
/** * In-memory TTL cache backed by an LRU cache to prevent memory leaks. */export class MemoryCache<T extends {}> { private lru: LRUCache<string, T>;
constructor(ttlMs: number, max = 1000) { this.lru = new LRUCache<string, T>({ max, ttl: ttlMs, ttlAutopurge: true }); }
get(key: string): T | undefined { return this.lru.get(key); }
set(key: string, value: T): void { this.lru.set(key, value); }
has(key: string): boolean { return this.lru.has(key); }
delete(key: string): void { this.lru.delete(key); }
clear(): void { this.lru.clear(); }}