Enhance Your Kotlin Apps: A Guide to Smart Caching Solutions

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

  1. If you have a conclusive benchmark and are willing to accept some coupling, put an object in the middle.
  2. Unit test all your invalidation scenarios. Experience shows that we face them in an incremental way.
  3. Look for a real-world cache metaphor and model it.

Visit Now