ARC (Adaptive Replacement Cache) Cache
ARC is an adaptive cache that adjusts between LRU and LFU.
Overview
ARC (Adaptive Replacement Cache) is an adaptive cache strategy that dynamically adjusts between LRU (Least Recently Used) and LFU (Least Frequently Used). It maintains two lists: T1 (recently used) and T2 (frequently used), and dynamically adjusts the size of both lists based on access patterns.
Features
- Hit Rate: 86%
- Memory Usage: Medium
- Concurrency: High
- Implementation Complexity: Medium
Use Cases
- Mixed access patterns
- Adaptive requirements
- Balanced performance
- Scenarios needing balance between LRU and LFU
Quick Start
Installation
Basic Usage
How It Works
ARC maintains four lists:
- T1: Items accessed once recently
- T2: Items accessed twice or more recently
- B1: Items recently evicted from T1
- B2: Items recently evicted from T2
Dynamically adjusts the size of T1 and T2 based on access patterns.
API Reference
Constructors
Main Methods
Performance Characteristics
- Time Complexity:
- Set: O(1)
- Get: O(1)
- Delete: O(1)
- Space Complexity: O(n), where n is cache capacity
Best Practices
- Mixed access patterns: ARC is suitable for scenarios with both temporal and frequency locality
- Adaptive requirements: Use when cache needs to automatically adjust between LRU and LFU
- Balanced performance: ARC provides stable performance across various access patterns