What are the common Redis caching patterns?
Redis caching patterns define how your application coordinates reads and writes between the cache and the source-of-truth database. Choosing the wrong pattern causes stale data, cache stampedes, or write amplification.
**Cache-aside (lazy loading)** is the most common pattern. The application checks Redis first; on a miss it fetches from the DB, writes the result to Redis with a TTL, and returns it. Reads that hit cold keys pay a latency penalty, but the cache only holds data that was actually requested. You own the invalidation logic, which makes it flexible but error-prone.
**Read-through** moves that miss-fill logic into a cache client library or sidecar. The application always talks to the cache; the cache fetches from the DB on misses transparently. This simplifies application code but requires a caching layer that understands your data model. It still suffers the cold-start penalty on first access.
**Write-through** writes to the cache and the database synchronously on every mutation. Reads are always fast because the cache is never stale. The cost is write latency (two writes per mutation) and wasted cache space for data that is written but never read.
**Write-behind (write-back)** writes to Redis immediately and asynchronously flushes to the database. This gives sub-millisecond write latency and can batch DB writes for efficiency. The risk is data loss if Redis crashes before the flush completes — acceptable for metrics or analytics, dangerous for financial records.
Two operational concerns apply to all patterns. **Cache stampede** happens when many requests simultaneously miss the same key (e.g., after TTL expiry). Mitigate with probabilistic early expiration, a mutex lock (Redis SET NX), or request coalescing. **Cache warming** matters at startup — a cold cache under full traffic can overwhelm the database. Pre-warm from a dump or route a fraction of traffic to the cache before full cutover.
In practice most systems combine patterns: cache-aside for reads, write-through for critical writes, and write-behind for high-frequency counters or event streams.
Names and defines at least three patterns correctly with one concrete trade-off each.
Covers all four patterns, explains cache stampede and mitigation, and articulates when to combine patterns based on consistency vs. latency requirements.
Reading the answer is step one. Explaining it unprompted — under interview pressure — is what actually matters. Get AI-graded feedback on your answer with follow-up probes on your weak points.
Get Graded — Free Assessment