Start here

This page teaches one idea: a cache answers a read so the database does not have to. You will guess first, then see the answer.

If you know this already, skip to the recall question.

A cache answers 9 of every 10 reads. 120 reads arrive each second. How many reads each second reach the database?
One read in ten misses the cache. 120 reads times one tenth is 12 reads each second.

Follow one read

Step through the path of one read. The blue box is where the read is now.

flowchart LR
  client[client]:::k1 --> cache[(cache)]
  cache --> db[(database)]
client (now) --> cache --> database
The client asks the cache first.
flowchart LR
  client[client]:::k2 --> cache[(cache)]:::k1
  cache -->|miss| db[(database)]
client --> cache (now, a miss) --> database
The cache has no copy. This is a miss, so it asks the database.
flowchart LR
  client[client]:::k2 --> cache[(cache)]:::k2
  cache --> db[(database)]:::k1
  db -->|answer, kept| cache
client --> cache --> database (now) --answer, kept--> cache
The database answers. The cache keeps a copy of the answer.
flowchart LR
  client[client]:::k2 --> cache[(cache)]:::k1
  cache -->|hit| client
  db[(database)]
client --> cache (now, a hit) --> client; the database is not asked
The next read for the same report is a hit. The database is not asked.

Try it

Change the values and watch the database load.

Reads that reach the database:

Recall

What does the cache do on a miss?
On a miss the cache asks the database and keeps the answer, so the next read for it is a hit.