Skip to content
StackDecode
System Design
7. Caching ArchitectureAnimated

Cache Consistency

Keeping cache and database in agreement.

The idea

Strategies include TTL, invalidation, versioning and write-through, each with different staleness.

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. 1Pick an acceptable staleness
  2. 2Choose a write strategy
  3. 3Invalidate on change
  4. 4Monitor mismatches

Where it is used

Data correctness.

Watch out for

Perfect consistency removes most caching benefit.

Related