/** * vapor-chamber - HTTP response cache + request deduplication * * Internal module used by createHttpClient. Not exported publicly. * * Cache entries carry a fresh window (`freshUntil`) and, when a caller opts * into `cache.staleTtl`, a longer stale window (`staleUntil >= freshUntil`). * Inside `freshUntil` -> a fresh hit (no fetch). Between the two -> a stale * hit: served instantly while the caller attaches a background revalidation * (see http.ts). Past `staleUntil` -> a miss, but the entry is NOT deleted - * `getAny` still finds it as a last resort for `cache.serveStaleOnError`. * Only LRU size pressure, an invalidation (a write, a group), `clearCache()` * or a `no-store` answer removes it. * * PER-CLIENT, NOT MODULE-GLOBAL. The cache key holds the request's headers * (Authorization, Accept-Language) but not cookies, so under concurrent SSR a * shared map lets * user A's authenticated payload answer user B's identical URL, and collapses * two users' concurrent requests into one in-flight promise. A fresh client * per request (whitepaper section 12.2) is a fresh cache - the same * factory-closure shape the bus-level `cache()` plugin uses. */ declare const CACHE_DEFAULT_TTL = 30000; type CacheEntry = { data: any; freshUntil: number; staleUntil: number; url: string; }; export type CacheHit = { data: any; stale: boolean; }; /** See ResponseCache.read. */ export type ReadTicket = { url: string; stale: boolean; }; export type ResponseCache = { /** A fresh or stale hit; `null` on a plain miss. Never deletes on read. */ get(key: string): CacheHit | null; /** Last-resort lookup for `cache.serveStaleOnError` - ignores freshness, never evicts. */ getAny(key: string): CacheEntry | null; /** `url` is what an invalidation matches: the key also holds the request's headers. */ set(key: string, data: any, ttl?: number, staleTtl?: number, url?: string): void; clear(): void; /** Drop the entries and in-flight reads whose URL `matches`, and mark the * matching `read` tickets stale: a write's URL and the URIs its answer * names (RFC 9111 4.4). */ invalidate(matches: (url: string) => boolean): void; /** Drop the entries whose stored response `inGroup` says yes to (RFC 9875 * groups). A read on the wire has groups nobody knows yet: every one is * marked not to be stored and no longer joined. A fetch, never stale data. */ invalidateStored(inGroup: (response: any) => boolean): void; /** Forget one entry: its response said `no-store`. */ drop(key: string): void; /** A cacheable read going on the wire. A read across an invalidation of ITS * URL may carry the value from before it, so `invalidate` marks its ticket; * an invalidation of another URL leaves it alone. */ read(url: string): ReadTicket; /** The read landed or failed: forget the ticket. True when it may be stored. */ done(ticket: ReadTicket): boolean; getInflight(key: string): Promise | undefined; /** A read others may join; `url` is what an invalidation matches. */ setInflight(key: string, promise: Promise, url: string): void; /** Stop new callers joining `promise` (its last holder aborted). Only its * own entry: after an invalidation the key may hold a newer read. */ dropInflight(key: string, promise: Promise): void; }; /** One cache + one dedupe map, owned by exactly one HTTP client. */ export declare function createResponseCache(): ResponseCache; export { CACHE_DEFAULT_TTL }; //# sourceMappingURL=http-cache.d.ts.map