Strategies
- TTL (Time To Live) — the cache lives N seconds, then is automatically deleted. Simple, but data may be stale before TTL expires
- Event-based — on data change, explicitly delete or update the relevant cache. Precise, but more complex to implement
- Write-through — write simultaneously to cache and DB. Always fresh cache at the cost of an extra write
- Cache-aside — read from cache; if absent, read from DB and cache the result. The most common strategy
Complexity
Challenges: cache stampede (many requests hitting the DB simultaneously after TTL expires), stale reads, and complex invalidation for related data.