caching
LFU Cache
Least Frequently Used — evicts the entry with the lowest access count
Capacity0 / 5
Max Frequency0
Evictions0
Cap
// frequency bars — click to access (↑ freq), lowest freq = eviction target
Cache empty — add items with PUT
// event log
No events yet.
// how it works
- Each entry tracks an access frequency counter
- GET and PUT increment the frequency
- On eviction, the lowest frequency entry is removed
- Ties broken by insertion order (oldest first)
- O(1) with min-heap or frequency buckets
// trade-offs
- Better than LRU for skewed access patterns
- Keeps genuinely hot data in cache
- New items start at freq=1, easily evicted
- Stale popular items can linger (no decay)