Invalidation strategies
On This Lesson 4 topics
This lesson is planned. The outline below lists the topics it will cover. The full lesson has not been published yet.
In this lesson
choose how entries stop being stale.
Planned topics
- TTL only: simple, but data is wrong for up to the TTL; unacceptable for prices.
- Explicit invalidation on write: delete the key in the same service that writes.
- Event-driven: the owner publishes
ProductUpdated; every cache subscriber evicts or refreshes. Works across services. - Best practice: events plus a TTL as a safety net for lost events.
- Deleting is safer than updating the cache: the next read loads the freshest data.
Draft outline details
Demonstration
| Strategy | Staleness | Cost |
|---|---|---|
| TTL only | up to TTL | none |
| Delete on write | tiny | coupling |
| Event + TTL | seconds | broker |
Check your understanding
Why keep a TTL when you have events?
Show answer
Events can be lost; the TTL bounds the damage.
Practice
Apply this lesson with the module's lab, exercises and quiz.
Marking a lesson complete is optional and you can undo it any time. Your progress stays in this browser.