An interactive web application for visualizing and understanding LFU (Least Frequently Used) cache eviction policies. Compare LFU vs LRU behavior side-by-side and build intuition for caching strategies through hands-on experimentation.
https://forging-moon.github.io/lfu-cache/
- Interactive LFU Cache: Adjust capacity (2-20 items) and perform get/put operations with real-time visual feedback
- Side-by-side Comparison: Toggle "Compare Mode" to see how LRU makes different eviction decisions on the same access pattern
- Pattern Playback: Auto-play preset patterns (sequential, hot keys, alternating, random) or input custom sequences
- Visual Feedback: Color-coded indicators for hits (green), misses (amber), and evictions (red)
- Frequency Visualization: Each cache entry displays its access frequency with gradient-colored badges
- Operation History: Complete log of all operations with timestamps and outcomes
- Hit/Miss Statistics: Real-time tracking of cache performance metrics
- Mobile Responsive: Works on 375px+ viewports with touch-friendly controls
- Adjust Capacity: Use the slider to set cache size (2-20 items)
- Manual Operations:
- Enter a key/value and click Put to add items
- Enter a key and click Get to retrieve items
- Pattern Playback: Select a preset pattern and click Play to watch cache behavior automatically
- Compare Mode: Toggle the switch to see LRU eviction decisions side-by-side
- Step Through: Use Step button to advance patterns one operation at a time
- Clear: Reset the cache to start fresh experiments
- Implementation: O(1) LFU using frequency buckets and hash maps
- Tie-breaking: When frequencies are equal, oldest entry (by insertion time) is evicted
- Stack: Vanilla HTML/CSS/JavaScript — no build step, no dependencies
- Deployment: GitHub Pages
git clone https://github.com/forging-moon/lfu-cache.git
cd lfu-cache
# Open index.html in your browser, or:
python3 -m http.server 8000MIT — Part of the Forging Moon collection of interactive computer science visualizations.