← Lessons

quiz vs the machine

Silver1100

System Design

The Read Through Cache

Making the cache itself responsible for fetching missing data from the store.

4 min read · intro · beat Silver to climb

What it is

A read through cache sits inline between the application and the database. The application always asks the cache for data and never talks to the database for reads. When the requested key is missing, the cache itself loads it from the backing store, saves it, and returns it.

How it differs from cache aside

  • In cache aside the application loads from the database on a miss.
  • In read through the cache provider loads from the database on a miss.

The logic lives in the cache layer, so application code is simpler and the loading behavior is consistent across all callers.

Trade offs

  • Application code is cleaner because loading is centralized.
  • The cache needs a loader function and must understand the data model.
  • The first request for a key still pays the slow database read.
  • Like cache aside, only accessed data is cached, matching the working set.

Key idea

A read through cache hides the database behind the cache, loading missing keys automatically so every reader sees one consistent path.

Check yourself

Answer to earn rating on the learn ladder.

1. Who fetches data from the database on a miss in a read through cache?

2. What is a key benefit of read through over cache aside?