All labs
Lab 39
Caching Strategies

Cache Eviction — LRU vs LFU vs FIFO

A tiny fixed-size cache and a stream of requests. Watch LRU, LFU and FIFO each evict a different victim when the cache fills — and compare their hit ratios on the same workload to see why the policy matters.

A 4-slot cache. Request keys (or run the demo) and watch each policy choose a different victim when the cache is full. Switch the policy and replay the same demo to compare hit ratios.
Cache (0/4)
empty
empty
empty
empty
request:
Hits
0
Misses
0
Hit ratio
0%

Run the demo under each policy and compare the hit ratio — same 10 requests, different evictions, different outcomes.

What just happened