Cache Consistency 00:00:01 A lock has to protect the right read and write An editor changes an item while another client is loading a cached copy. A simple lock might appear to settle the disagreement. Name who acquires it and whether every participant honors the same protocol. Cache and database both hold v1. The writer wants v2. The reader must wait from now on. The cache is behind for a moment, but nobody may look. The old value is gone before the write is confirmed. The reader gets the lock, misses and fills v2. A strong application guarantee needs a defined authority and complete coordination across failure paths. Calling a cache operation atomic does not make a separate database update atomic. 00:00:46 A stale copy can still be an allowed answer The latest authoritative value changes before an asynchronously refreshed copy catches up. Compare the answers readers can receive during the propagation gap. Both hold v1. No lock is taken. v2 is committed and confirmed at once. A reader still gets v1. The message has been sent and not yet applied. The key is deleted, the next read fills v2. Eventual convergence under the stated delivery assumptions gives no fixed freshness deadline. If the user needs a maximum age, measure and enforce that additional contract. 00:01:25 A slow refill can overwrite the future Pause a cache loader after it reads the old database version. Let the writer commit a new version, then resume the paused loader. Which copy would an unguarded set install? The reader finds nothing and reads version 1 from the database. Then it pauses. The writer commits version 2. There is no copy to remove. A plain cache learns nothing from it. The reader wakes up and stores v1. Everybody reads v1 until the TTL. The same delete, but now the cache remembers: newest is version 2. Version 1 is lower than 2, so the fill is dropped. The next read loads v2. Compare versions at the cache write boundary or use a compatible invalidation protocol. A database commit cannot prevent a delayed message from arriving afterward. 00:02:18 An invalidation disappears The authoritative update succeeds, but its cache deletion never arrives. The application's writer may already have returned success. Follow the old value until another mechanism finally repairs it. v2 is in the database. The app dies before the delete. Readers get v1 until the copy expires. The same commit stored the row: delete this key. A worker reads the row and deletes the key. If it fails it tries again. Retained change records, bounded lifetimes and reconciliation offer different repair paths. Specify how long readers may remain stale when the ordinary invalidation path is broken. 00:03:02 The final seat has one authoritative owner Two customers can read the same apparently free seat from a convenient cache. Even a brief freshness delay matters when the next operation grants exclusive ownership. The cache says 1 seat. Two people see it, and that is fine. One conditional update takes the seat: only if the count is above zero. The same update changes no row. The stale page did no harm. Keep discovery fast, then make the irreversible seat claim conditional at the authority. A useful cached description and a correct exclusive reservation need different guarantees.