All notes

A cache miss is part of the design.

Quick summary
  • On a cache miss, read from the source and fill the cache before returning the result.
  • Design the fallback for concurrent misses and cache outages.
  • Use expiry to limit staleness and invalidation to respond to changes at the source.

A cache is a shortcut to data, so the application still needs a path to the source. In a cache-aside flow, the application checks the cache first. On a miss, it reads the database, places that result in the cache, and returns it.

The interesting questions live around that simple flow: how long may a value be stale? What happens when many requests miss together? If the cache is unavailable, can the database absorb the traffic?

A useful design exercise: draw the miss path before the hit path. Then describe expiry and invalidation separately. Expiry limits how long a cached value stays around; invalidation responds to a change in the underlying data.

Find this note on the workbench