import type { EponymeCacheFailureContext } from '../../types/hooks.js'; /** * Most keys the in-process tier holds. Without one, a key read once stays referenced with its payload for * the life of the process, since nothing sweeps an entry that is never read again. */ export declare const MAX_LOCAL_ENTRIES = 500; export interface EponymeSharedCacheStorage { getItem(key: string): Promise; setItem(key: string, value: T, options?: { ttl?: number; }): Promise; removeItem(key: string): Promise; getKeys(prefix?: string): Promise; } export declare class EponymeCache { /** Insertion order is access order: a hit is re-inserted, so the oldest key is the least recently used. */ private readonly local; private readonly ttlMs; private readonly ttlSeconds; private readonly localMs; private readonly resolveShared; private readonly onFailure; /** Bumped by every invalidation, so a read in flight can tell that what it holds is now out of date. */ private invalidations; private readonly warnedAt; constructor(options?: { cacheSeconds?: number; storage?: () => EponymeSharedCacheStorage | undefined; onFailure?: (context: EponymeCacheFailureContext) => void; }); /** * Resolved per call rather than held: `useStorage()` needs Nitro to be running, and the service is built * on first request, not on import. */ private shared; get(key: string, load: () => Promise): Promise; /** Makes room for one key: expired entries first, then the least recently used ones. */ private evict; private read; /** The current invalidation token, or `null` when there is no shared tier or it cannot be read. */ private invalidationToken; /** Replaces the invalidation token, which is what tells the other instances that a read is now late. */ private markInvalidated; /** * Reports a shared-tier failure without ever failing on it. The hook fires every time, for a collector * that counts them; the log is throttled per kind, for a human reading it. */ private report; drop(key: string): Promise; /** * Drops every key under `prefix`, which is how one write clears the several cached shapes of a listing at * once. */ dropPrefix(prefix: string): Promise; }