/** * Small in-memory TTL cache tailored to the cache API used by Enbox. * * Expired entries are purged by an unref'd background timer and are also checked on access. `cancelTimer()` only stops * the background timer; `get()` and `has()` still remove stale entries. */ export declare class TtlCache implements Iterable<[K, V]> { max: number; noDisposeOnSet: boolean; noUpdateTTL: boolean; ttl?: number; updateAgeOnGet: boolean; private readonly _data; private readonly _dispose?; private _sequence; private _timer?; private _timerExpiresAt; constructor(options?: TtlCache.Options); /** * Total entries currently held in the cache. */ get size(): number; /** * Store a value and assign the configured TTL. */ set(key: K, value: V, options?: TtlCache.SetOptions): this; /** * Retrieve a cached value, optionally extending the entry age. */ get(key: K, options?: TtlCache.GetOptions): T | undefined; /** * Check whether a live value exists for the given key. */ has(key: K): boolean; /** * Delete a cache entry. */ delete(key: K): boolean; /** * Clear all cache entries. */ clear(): void; /** * Remove expired entries. */ purgeStale(): boolean; /** * Return the remaining TTL for a live entry. */ getRemainingTTL(key: K): number; /** * Set a new TTL for an existing entry. */ setTTL(key: K, ttl?: number | undefined): void; /** * Iterate over live entries from soonest to latest expiration. */ entries(): Generator<[K, V]>; /** * Iterate over live keys from soonest to latest expiration. */ keys(): Generator; /** * Iterate over live values from soonest to latest expiration. */ values(): Generator; /** * Cancel the background purge timer. Lazy expiry checks still run on access. */ cancelTimer(): void; [Symbol.iterator](): Iterator<[K, V]>; private _expirationFromTtl; private _isExpired; private _purgeToCapacity; private _purgeStaleAndSelectEviction; private _isEarlierEntry; private _purgeStale; private _sortedEntries; private _delete; private _scheduleTimer; private _scheduleNextTimer; } export declare namespace TtlCache { type DisposeReason = 'evict' | 'set' | 'delete' | 'stale'; type Disposer = (value: V, key: K, reason: DisposeReason) => void; type TTLOptions = { noUpdateTTL?: boolean; ttl?: number; }; type Options = TTLOptions & { dispose?: Disposer; max?: number; noDisposeOnSet?: boolean; updateAgeOnGet?: boolean; }; type SetOptions = { noDisposeOnSet?: boolean; noUpdateTTL?: boolean; ttl?: number; }; type GetOptions = { ttl?: number; updateAgeOnGet?: boolean; }; } //# sourceMappingURL=cache.d.ts.map