Back to roadmap
Module 8 · Caching, Queues, Async WorkDay 07220 min

Eviction Policies

When the cache is full, who loses?

Day 072

Eviction Policies

LRU
note
LFU
note
ARC
note
FIFO
note
Memory hook

Eviction Policies: when the cache is full, who loses?

Mental model

absorb bursts before they become outages

Design lens

Wrong policy hurts hit rate without warning.

Recall anchors
LRULFUARC

Why it matters

Eviction picks which key to drop when memory is full. LRU drops the least-recently-used. LFU drops the least-frequently-used. ARC adapts between them. Choose by workload.

Deep dive

LRU is fine for scan-resistant patterns and recent-access dominance.

LFU is better for skewed access where popular keys persist.

ARC keeps two lists and balances; mostly an OS-level trick.

Demo / scenario

Session cache fills up nightly.

  1. LRU: idle sessions evict first — sensible.
  2. LFU: very-frequent users evict last; midnight stragglers churn.
  3. Add maxmemory + allkeys-lru in Redis.

Tradeoffs

  • Wrong policy hurts hit rate without warning.
  • Per-key TTLs combine with eviction.
  • Monitor evictions/sec — spikes mean undersized cache.

Diagram

LRU
LFU
ARC
FIFO
Eviction comparison.

Mind map

Check yourself

Loading quiz…

Sources & further reading