← All cheatsheets

System Design

Caching Strategies & Invalidation

The read/write patterns (cache-aside, read/write-through, write-back), eviction policies (LRU/LFU/TTL), and the two hard problems — stale reads and the thundering herd — with the mitigations that actually work.

Updated August 30, 2026 · 5 min read

Read/write patterns

Cache-aside (lazy)App checks cache, loads from DB on miss, then populates.Most common; cache can go stale until TTL.
Read-throughCache library loads from DB on miss transparently.
Write-throughWrite hits cache and DB synchronously.Consistent, slower writes.
Write-back (write-behind)Write to cache, flush to DB async.Fast writes; risk of loss on crash.
Write-aroundWrite straight to DB, skip cache.Avoids caching write-once data.

Eviction policies

LRUEvict least-recently-used.Good default for temporal locality.
LFUEvict least-frequently-used.Better for stable hot sets.
TTLExpire after a fixed time.Simple staleness bound.
FIFO / randomCheap, ignores access pattern.

The hard problems

Stale readsCache diverges from source.Bound with TTL, or invalidate on write.
Thundering herd / stampedeA hot key expires and every request hits the DB at once.Fix: request coalescing, jittered TTLs, probabilistic early refresh.
Hot keysOne key gets disproportionate traffic.Fix: local (L1) cache, key replication.
Cold startEmpty cache after deploy/restart floods the DB.Fix: warm-up, gradual ramp.

In the interview

  • “There are only two hard things: cache invalidation and naming things.” Name your invalidation strategy explicitly — TTL, write-through, or versioned keys — before the interviewer asks.
  • Pick the write pattern from the workload: write-through for correctness-sensitive data, write-back only when you can tolerate loss for throughput.
  • The thundering herd is the classic follow-up. Have coalescing or jittered TTL ready before you’re asked what happens when the hot key expires.