Build a Cache with Pluggable Eviction

Strategy pattern

Challenge 1 of Make It PluggableBeginner~55 minFree

One cache, three eviction policies, swappable at runtime, the Strategy pattern made real. Build FIFO, LRU, and LFU policies (each a small data-structure exercise), plug them into a single capacity-bound cache, and hot-swap the algorithm without touching the cache code.

5 steps

  1. 1The Strategy Interface + FIFO
  2. 2The LRU Policy
  3. 3The LFU Policy
  4. 4The Cache
  5. 5Swapping the Strategy
Start step 1