System Design
7. Caching ArchitectureAnimated
Cache Invalidation
Removing or updating cached data when the source changes.
The idea
One of the hard problems in computing. Options: delete on write, update on write, or expire with TTL.
Watch it work
Press play, pause, or step through. Some animations have settings you can change.
- client
- gateway / proxy
- service
- cache
- data store
- queue / stream
Check the in-process cache: nanoseconds.
- step:
- 1/4
- at:
- Request
1/10
The green dot is a request moving through the system.
Step by step
- 1Data changes at the source
- 2Delete or update the cache entry
- 3Next read reloads fresh data
- 4Optionally broadcast to other caches
Where it is used
Keeping caches correct.
Watch out for
Race conditions can reinsert stale data.