Skip to content
StackDecode
System Design
7. Caching ArchitectureAnimated

Write-Through Cache

Writes go to the cache and database together.

The idea

Each write updates the cache and then the database synchronously, keeping them consistent.

Watch it work

Press play, pause, or step through. Some animations have settings you can change.

RequestL1 in-processL2 RedisDatabase
  • client
  • gateway / proxy
  • service
  • cache
  • data store
  • queue / stream

Check the in-process cache: nanoseconds.

step:
1/4
at:
Request
1/10

The green dot is a request moving through the system.

Step by step

  1. 1App writes to the cache
  2. 2The cache writes to the database
  3. 3Both are updated
  4. 4Acknowledge

Where it is used

Data that is read soon after writing.

Watch out for

Slower writes, and cache fills with rarely read data.

Related