Adaptive Replacement Cache (ARC)
What you'll learn: How ARC automatically balances between keeping recently-used and frequently-used items in cache by intelligently adjusting its strategy over time.
The Core Problem
Both LRU (keeps recent items) and LFU (keeps frequent items) have weaknesses. LRU can't handle repeating patterns well, while LFU struggles with recent bursts of activity. What if your cache could learn which strategy works better for your current workload and adjust automatically?
How ARC Works
Imagine you have two separate LRU lists:
- List T₁: Recently-used items (seen once)
- List T₂: Frequently-used items (seen multiple times)
The clever part: ARC maintains a movable partition between these lists. It tracks which evictions would have been hits if you'd made the cache bigger in one direction or the other.
When you have cache misses that would've been hits with a bigger T₁, ARC grows T₁ and shrinks T₂. When misses would've been hits with a bigger T₂, it does the opposite.
Simple Mental Model
Think of it like a sliding thermostat. If you're too cold (missing recent items), slide toward "recency mode." If you're still uncomfortable (missing frequent items), slide toward "frequency mode." ARC automatically finds the sweet spot for your specific access patterns.
The Advantage
Unlike fixed LRU or LFU, ARC adapts to changing workloads—morning traffic might be recency-heavy, afternoon might favor frequency. You get better hit ratios without manual tuning.
Key Takeaway: ARC dynamically balances recency (LRU-style) and frequency (LFU-style) caching by maintaining two adaptive LRU lists, automatically adjusting their sizes based on observed access patterns for superior performance across diverse workloads.