//#region src/storage/cache.d.ts /** * LRU (Least Recently Used) cache implementation. * Based on the Go iavl cache/cache.go implementation. * * Uses a doubly-linked list + Map for O(1) operations: * - add: O(1) * - get: O(1) * - has: O(1) * - remove: O(1) */ /** * Cache interface for generic key-value caching. */ interface Cache { /** * Adds a value to the cache with the given key. * If the cache is full, evicts the least recently used entry. * If the key already exists, updates the value and moves it to front. * * @param key - The key to cache * @param value - The value to cache * @returns The evicted value if cache was full, undefined otherwise */ add(key: K, value: V): V | undefined; /** * Retrieves a value from the cache. * If found, marks the entry as recently used. * * @param key - The key to look up * @returns The cached value, or undefined if not found */ get(key: K): V | undefined; /** * Checks if a key exists in the cache. * Does not update LRU ordering. * * @param key - The key to check * @returns true if the key exists, false otherwise */ has(key: K): boolean; /** * Removes a key from the cache. * * @param key - The key to remove * @returns The removed value, or undefined if not found */ remove(key: K): V | undefined; /** * Gets the current number of entries in the cache. * * @returns The number of cached entries */ size(): number; /** * Gets the maximum capacity of the cache. * * @returns The maximum number of entries */ capacity(): number; } /** * LRU cache implementation using a doubly-linked list and Map. * * Provides O(1) time complexity for all operations: * - add: O(1) * - get: O(1) * - has: O(1) * - remove: O(1) */ declare class LRUCache implements Cache { private dict; private list; private maxSize; /** * Creates a new LRU cache with the specified capacity. * * @param maxSize - Maximum number of entries to cache */ constructor(maxSize: number); add(key: K, value: V): V | undefined; get(key: K): V | undefined; has(key: K): boolean; remove(key: K): V | undefined; size(): number; capacity(): number; } //#endregion export { Cache, LRUCache }; //# sourceMappingURL=cache.d.cts.map