import { StoryRuntime } from './story-types.js'; /** * A bounded LRU cache for {@link StoryRuntime} instances. * * Entries are keyed by canonical story key (produced by {@link buildStoryKey}). * The cache maintains insertion/access order via a doubly linked list so that * eviction targets the least recently used non-body entry. * * @example * ```ts * const cache = new StoryRuntimeCache(10); * cache.set('fn:12', footnoteRuntime); * const rt = cache.get('fn:12'); // promotes to most-recently-used * ``` */ export declare class StoryRuntimeCache { private readonly capacity; private readonly map; /** Sentinel head (most recently used). */ private readonly head; /** Sentinel tail (least recently used). */ private readonly tail; constructor(capacity?: number); /** * Retrieves a cached runtime by story key. * * Accessing an entry promotes it to the most-recently-used position. * * @param storyKey - Canonical story key. * @returns The cached runtime, or `undefined` if not present. */ get(storyKey: string): StoryRuntime | undefined; /** * Inserts or updates a runtime in the cache. * * If the cache is at capacity, the least recently used non-body entry * is evicted first. * * @param storyKey - Canonical story key. * @param runtime - The runtime to cache. */ set(storyKey: string, runtime: StoryRuntime): void; /** * Removes a runtime from the cache. * * The runtime's `dispose` callback is **not** called — this is an * explicit removal, not an eviction. * * @param storyKey - Canonical story key. * @returns `true` if the entry existed and was removed. */ delete(storyKey: string): boolean; /** * Removes all entries from the cache. * * Calls `dispose` on every cached runtime that has one. */ clear(): void; /** * Removes an entry and disposes its runtime. * * Unlike {@link delete}, this calls `dispose` on the removed runtime, * making it suitable for cache invalidation after part mutations. * * @param storyKey - Canonical story key. * @returns `true` if the entry existed and was invalidated. */ invalidate(storyKey: string): boolean; /** * Invalidates all entries whose keys start with the given prefix. * * Useful for bulk-invalidating all notes (`'fn:'`, `'en:'`) or all * header/footer runtimes (`'hf:'`) after a part mutation. * * @param prefix - The key prefix to match (e.g., `'fn:'`). * @returns The number of entries invalidated. */ invalidateByPrefix(prefix: string): number; /** * Returns `true` if the cache contains an entry for the given story key. * * Does NOT promote the entry — use {@link get} if you intend to read it. * * @param storyKey - Canonical story key. */ has(storyKey: string): boolean; /** The number of entries currently in the cache. */ get size(): number; /** Detaches a node from its current position in the list. */ private detach; /** Inserts a node immediately after the head sentinel (most recent). */ private attachAfterHead; /** * Evicts the least recently used non-body entry. * * Scans backward from the tail sentinel to find the first eviction * candidate (any entry whose key is not the body story key). */ private evictLru; } //# sourceMappingURL=runtime-cache.d.ts.map