# LRU Cache A LRU (Least Recently Used) Cache implementation provides efficient caching with automatic eviction of least recently used items when the cache reaches its maximum size. ## API ```typescript // LRU cache implementation export declare class LRUCache { constructor(maxSize?: number); has(k: T): boolean; get(k: T): U | undefined; set(k: T, v: U): void; pop(k: T): U | undefined; } // Creates a memoized function with LRU caching export declare function cached(options: { maxSize: number; getKey: (args: Args) => T; getValue: (args: Args) => V; }): ((...args: Args) => V) & { cache: LRUCache; pop: (...args: Args) => V }; // Creates a simple memoized function with default settings export declare function simpleCache(getValue: (args: Args) => V): (...args: Args) => V; ``` ## Example ```typescript import { LRUCache } from '@welshman/lib'; // Create cache with max size of 3 const cache = new LRUCache(3); // Add items cache.set('a', 1); cache.set('b', 2); cache.set('c', 3); console.log(cache.get('a')); // 1 // Adding 'd' will evict 'b' (least recently used) cache.set('d', 4); console.log(cache.has('b')); // false console.log(cache.has('a')); // true (recently accessed) ```