/** * Keyed in-memory store with periodic stale-entry sweep. Internal helper for * the rate-limit primitives — keep it package-private (re-export only via * `infra/rate-limit/index.ts` if a real consumer appears). * * Lifecycle: `new` → use → `destroy()`. Buckets created from this store are * registered in the gateway's bucket registry, which calls `destroy()` on * graceful shutdown so the cleanup timer doesn't leak. */ export type Clock = () => number; export type KeyedStoreOptions = { /** Drop entries whose `lastTouchedMs` is older than this. */ staleAfterMs: number; /** How often the sweep runs. Defaults to `staleAfterMs / 4` (capped at 10min). */ cleanupIntervalMs?: number; /** Injected clock for deterministic tests. */ clock?: Clock; }; export declare class KeyedStore { private readonly map; private readonly clock; private readonly staleAfterMs; private cleanupTimer?; constructor(opts: KeyedStoreOptions); get(key: string): V | undefined; set(key: string, value: V): void; delete(key: string): void; size(): number; clear(): void; destroy(): void; private sweep; }