Skip to content

Write-Through Cache

One-Liner

Writes synchronously update both cache and primary database.

What It Is

A caching strategy where each write operation updates the cache and the underlying data store before returning success.

Why It Exists

  • Ensures reads from cache reflect the latest data
  • Simplifies read paths
  • Reduces staleness-related bugs for read-heavy systems

How It Works

  1. Client issues a write
  2. Application writes to cache
  3. Application writes to database
  4. Operation succeeds only if both succeed

Tradeoffs

Pros

  • Strong consistency for cached reads
  • Simple read logic

Cons

  • Increased write latency
  • Cache becomes part of the write critical path
  • Harder failure handling

Failure Modes

  • Cache write succeeds, DB write fails → corrupted cache
  • Cache outage blocks writes entirely
  • Partial failures require rollback or invalidation strategies

Interview Traps

  • Claiming “strong consistency” without discussing failure handling
  • Ignoring write path latency
  • Treating cache as the source of truth

Real-World Usage

Useful in read-heavy systems with strict correctness needs and low write throughput.

Anti-Patterns

  • High write-rate systems
  • Using write-through when cache reliability is lower than the DB
  • Write-back cache
  • Read-through cache