System Design
7. Caching ArchitectureAnimated
Cache Expiration
Entries are dropped after a set time or condition.
The idea
Expiration bounds how stale data can be.
Watch it work
Press play, pause, or step through. Some animations have settings you can change.
- hit
- current request
A is missing: fetch it from the database and store it.
- step:
- 1
- hits:
- 0
1/22
Eviction policy: oldest inserted.
Step by step
- 1Store with an expiry
- 2Serve while valid
- 3Remove when expired
- 4Reload on next access
Where it is used
Bounding staleness.
Watch out for
Many keys expiring together cause a stampede. Add jitter.