Database: Cache Invalidation Done Right

You add a Redis cache in front of a database, and now users see stale data. Explain the invalidation strategy that fixes it.

Technical Reference & Key Concepts

The Challenge: Stale Cache

An API reads frequently from Redis and falls through to Postgres on miss. After edits, users still see the old value. Data consistency matters (it's a product catalog with prices).

Core questions to address:

  1. Why does a TTL-only approach still serve stale data, and what's the worst case?
  2. What invalidation strategy would you use — and what are its failure modes?
  3. How do you handle the read-path races (concurrent miss + write)?