Cache Sizing & Eviction Simulator (LRU, LFU, FIFO)
Interactive step-by-step visualizer for cache replacement policies (LRU, LFU, FIFO). Observe real-time hit/miss rates, memory state transitions, and item evictions.
Step-by-Step Cache Memory Progression
| Step | Request | Result | Evicted | Cache State (Left: Oldest $\rightarrow$ Right: MRU) |
|---|---|---|---|---|
| #1 | A | MISS | — | A |
| #2 | B | MISS | — | AB |
| #3 | C | MISS | — | ABC |
| #4 | D | MISS | Evicted "A" | BCD |
| #5 | A | MISS | Evicted "B" | CDA |
| #6 | B | MISS | Evicted "C" | DAB |
| #7 | E | MISS | Evicted "D" | ABE |
| #8 | A | HIT | — | BEA |
| #9 | B | HIT | — | EAB |
| #10 | C | MISS | Evicted "E" | ABC |
| #11 | D | MISS | Evicted "A" | BCD |
| #12 | E | MISS | Evicted "B" | CDE |
How to use this tool
Choose LRU (Least Recently Used), LFU (Least Frequently Used), or FIFO (First In First Out).
Pick cache capacity (2 to 6 slots) and enter a comma-separated stream of key accesses.
Follow the execution table to see exact cache hits, misses, and which item was evicted at each step.
Frequently Asked Questions
How is an LRU cache implemented in software?
LRU caches are typically implemented using a Doubly-Linked List combined with a Hash Map (O(1) lookup and O(1) node relocation to head upon access). In Java, LinkedHashMap(capacity, loadFactor, true) provides built-in LRU ordering.
What is the difference between LRU and LFU?
LRU evicts the item that has not been accessed for the longest time. LFU tracks an access counter per item and evicts the item with the lowest historical frequency, which prevents sudden one-off scans from polluting the cache.
What is Belady's Anomaly in FIFO caching?
Belady's Anomaly is a counter-intuitive phenomenon where increasing the cache capacity in FIFO replacement actually increases the number of cache misses for certain access patterns.
Which cache eviction algorithm does Redis use?
Redis implements approximated LRU, approximated LFU, volatile-lru (expiring keys only), and allkeys-random. Approximated LRU samples a small set of keys (e.g. 5) and evicts the best candidate, saving memory over maintaining explicit pointer lists.
Deepen your architecture knowledge with practical, production-tested guides:
Client-Side Privacy Guarantee
This tool never transmits your payloads to any server. Open DevTools (F12) → Network tab to verify that zero HTTP requests are sent while using this page.