The Problem of Many Copies
In a distributed system the same key may live in dozens of local caches. When the underlying value changes, every cached copy is suddenly wrong. Cache coherence is the discipline of keeping those copies consistent, or at least bounding how wrong they can be.
Strategies
- TTL only lets copies expire on their own. It is simple but every node can be stale up to a full TTL.
- Invalidation broadcast publishes a message on update so each node drops the key. It is fast but a missed message leaves a node stale.
- Versioned keys embed a version in the key so a new value is a new key and old copies age out naturally.
- Lease based schemes grant a node temporary ownership and require renewal before serving.
The Hard Part
Invalidation is a distributed delivery problem. A broadcast can be lost, reordered, or delayed, so most designs combine a short TTL with invalidation: the broadcast handles the common case quickly and the TTL is the backstop that bounds staleness when a message is missed.
Key idea
Coherence across nodes pairs invalidation broadcasts for speed with a short TTL as a backstop, since any single broadcast can be lost or delayed.