/** * `createResponseCache` — bounded, tiered-TTL, in-memory response cache for * billed / rate-limited APIs. * * Hoists the cache triplicated across flightaware / viator / tripadvisor: * per-key `Map` of `{ expiresAt, value }`, a short `dynamic` tier for live data * and a long `static` tier for reference data (airports, canonical lookups), * a hard entry bound with expired-first-then-oldest eviction, and an * injectable clock for deterministic tests. Pair the TTLs with * `readTtlMsEnv('_CACHE_TTL', …)` / `readTtlMsEnv('_STATIC_CACHE_TTL', …)`. * * Writes must never be cached — only route reads through this. */ /** Default maximum number of live entries (the donor fleets' shared bound). */ export declare const RESPONSE_CACHE_MAX_ENTRIES = 256; /** Options for {@link createResponseCache}. */ export interface ResponseCacheOptions { /** * TTL per tier, in milliseconds. `dynamic` is the default tier; add any * named tiers you need (the fleet convention is `static` for reference * data). A tier with TTL `0` never stores — caching disabled. */ ttlMs: { dynamic: number; } & Record; /** Max live entries before eviction. Defaults to {@link RESPONSE_CACHE_MAX_ENTRIES}. */ maxEntries?: number; /** Injectable clock (defaults to `Date.now`) — for tests. */ now?: () => number; } /** The cache returned by {@link createResponseCache}. */ export interface ResponseCache { /** * The cached value for `key`, or `undefined` on miss/expiry. Tiers matter at * WRITE time only — the TTL is baked into the entry by {@link set} / * {@link fetchThrough} — so lookups take no tier. */ get(key: string): V | undefined; /** Store `value` for `key` under `tier`'s TTL (no-op when that TTL is 0). */ set(key: string, value: V, tier?: string): void; /** Cache-through read: return the cached value or run `load` and cache it. */ fetchThrough(key: string, load: () => Promise, tier?: string): Promise; /** Drop everything. */ clear(): void; /** Number of entries currently held (including not-yet-swept expired ones). */ readonly size: number; } /** * Build a bounded in-memory TTL cache with named tiers. Keys are caller-chosen * — the donors key on the full request path (and body, for POST-read APIs like * viator). Eviction on insert when full: expired entries first, then the * oldest by insertion order. */ export declare function createResponseCache(opts: ResponseCacheOptions): ResponseCache; //# sourceMappingURL=response-cache.d.ts.map