System design · interactive
Cache invalidation
The app reads a price through a cache: on a miss it loads from the database and caches it for 60 s. At 15 s the price changes from 10 to 12. Which reads still see 10?
Reads every 10 s · write at 15 s
- 0 s10miss → DB
- 10 s10cache
- 20 s10cache
- 30 s10cache
- 40 s10cache
- 50 s10cache
- 60 s12miss → DB
- 70 s12cache
- 80 s12cache
- 15 s: UPDATE price = 12 (cache untouched)
4 stale reads
The cache keeps serving the old price until the entry expires at 60 s: 4 stale reads.
On write
Step 1 of 4 · read left to right
In production
Tools and technologies
Every cache layer needs an invalidation story.
Not tied to one language — use these names when you search docs or design a system.