FBR (Frequency-Based Replacement) Cache
FBR is a frequency-based replacement cache.
Overview
FBR (Frequency-Based Replacement) is a cache eviction strategy based on access frequency. It tracks the access frequency for each key, and when the cache is full, it evicts the key with the lowest access frequency.
Features
- Hit Rate: 78%
- Memory Usage: Medium
- Concurrency: Medium
- Implementation Complexity: Medium
Use Cases
- Frequency-based access
- Hot data retention
- Cold data eviction
- Scenarios needing clear distinction between hot and cold data
Quick Start
Installation
Basic Usage
How It Works
FBR maintains access frequency for each key:
When evicting, prioritizes evicting keys with the lowest access frequency.
API Reference
Constructors
Main Methods
Performance Characteristics
- Time Complexity:
- Set: O(log n)
- Get: O(log n)
- Delete: O(log n)
- Space Complexity: O(n), where n is cache capacity
Best Practices
- Hot data retention: FBR can effectively retain hot data
- Cold data eviction: Suitable for scenarios needing to quickly evict cold data
- Large frequency differences: Suitable for scenarios with large access frequency differences