Skip to content
Theory · Caching at system level · lesson 3 of 7

Staleness and TTL

A manager lowered the price of a coffee machine, yet buyers keep seeing the old one for a long time. The copy in the cache does not know the database has changed. In an interview this is the next question after "where is the cache": how long may the copy lie, and what removes it. The answer starts with the requirements, not with the cache.

In this lesson

  • A key's time to live
  • Deleting on write
  • The TTL as insurance
  • TTL and eviction
  • At checkout — from the database
  • Common mistake
  • Key points