TL;DR — Caches discusses the problems with caching, such as coupling and maintainability, and proposes solutions like using an object mediator, testing invalidation scenarios, and modeling real-world cache metaphors. It concludes that caches should be functional, and intelligent, and domain objects shouldn’t be cached.
Problem
- Coupling
- Testability
- Cache Invalidation
- Maintainability
- Premature Optimization
- Erratic Behavior
- Lack of Transparency
- Non-Deterministic Behavior
Solution
- If you have a conclusive benchmark and are willing to accept some coupling, put an object in the middle.
- Unit test all your invalidation scenarios. Experience shows that we face them in an incremental way.
- Look for a real-world cache metaphor and model it.