backendsystem-design
Cache invalidation gets easier when the source of truth is clear
Anonymous
Treat the database as authoritative and the cache as a derived copy. After a write, either update both with a carefully ordered flow or evict the cached key and let the next read refill it. Eviction is simpler, but a read racing with the write can briefly repopulate stale data; TTL bounds how long stale entries remain, not whether every read is fresh.
0