Skip to content
StackDecode
System Design
7. Caching ArchitectureAnimated

Database Caching

Caching query results or pages near the database.

The idea

Buffer pools keep hot pages in memory; query caches or Redis store results.

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. 1Query arrives
  2. 2Check the cache
  3. 3On miss run the query
  4. 4Store the result

Where it is used

Read-heavy databases.

Watch out for

Writes must invalidate affected entries.

Related