The Stale Cache
Something is wrong with the prices. Watch one copy age.
Lumen Market's shoppers keep paying old prices. Find out why, and stop it.
A cache keeps a copy of an answer close to the reader, so most reads skip the database. The copy starts ageing the moment it is stored.1
At Lumen Market, the price of a litre of oat milk changes every six minutes, and shoppers ask for it once a minute. The cache keeps each copy for its time to live, the TTL, and then deletes it.2 If the price changes before the copy expires, shoppers pay the old price.
Watch one copy age while the price moves.
References
- 1. The System Design Primer, Cache: When to update the cache (cache-aside, write-through). Donne Martin, CC BY 4.0, commit ae9bbd7.
- 2. Valkey documentation, commands/expire.md: Keys with an expire; How Valkey reclaims expired keys. Valkey project, CC BY-SA 4.0, commit 3298309.
Numbered ideas come from these sources, rewritten in our own words. Everything else, including the simulation and its numbers, was written for Vel Orendis.
Minute 0. A shopper misses the cache, so the price comes from the database: 3.40. The cache keeps a copy.
When you have watched the copy go stale, open the live cache.