Class representing an LFU (Least Frequently Used) Cache.
Evicts the least frequently used items when the cache reaches its maximum capacity.
Example
constcache = newLFUCache<string, number>(2); // Cache with capacity of 2 items cache.put('a', 1); cache.put('b', 2); console.log(cache.get('a')); // Outputs: 1 cache.put('c', 3); // 'b' is evicted because it is the least frequently used console.log(cache.get('b')); // Outputs: null (since 'b' was evicted)
Class representing an LFU (Least Frequently Used) Cache. Evicts the least frequently used items when the cache reaches its maximum capacity.
Example