Eviction & failure modes
- LRU eviction
- Drop least-recently-used keys when full. The usual default.
- TTL
- Expire keys after N seconds — a safety net that bounds staleness.
- Thundering herd / stampede
- A hot key expires; thousands of requests miss at once and hammer the DB. Fix: request coalescing/lock, jittered TTLs, serve stale while refreshing.
- Hot key
- One key gets huge traffic (a celebrity). Fix: local in-process cache, replicate the key.
- Cache penetration
- Requests for keys that don't exist always miss. Fix: cache negative results, bloom filter.
1. Why delete the cache key on update instead of writing the new value?
2. A homepage key expires and DB CPU spikes to 100%. Name for this?
Answered 0 / 2
Explain When should you NOT add a cache?