When data changes, cache and database can diverge:
Read-through: Cache fetches from DB on miss, caches result. Simple but first request is slow.
Write-through: Write to cache, cache writes to DB. Always consistent but higher write latency.
Write-around: Write directly to DB, invalidate cache. Cache fills on next read.
Write-behind: Write to cache, async write to DB. Fast but risky (data loss if cache fails).
Choosing:
- Read-heavy, stale OK: Read-through + TTL
- Write-heavy, consistency matters: Write-through
- Best performance, risk acceptable: Write-behind