feat: Add LFU Eviction Policy with LRU tie-breaking#90
Open
mariambadir wants to merge 1 commit into
Open
Conversation
Comment on lines
+1
to
+4
| """ | ||
| Unit tests for LFUEvictionPolicy. | ||
| Run with: pytest tests/test_lfu_eviction_policy.py -v | ||
| """ |
Collaborator
There was a problem hiding this comment.
Please move the test to the respective unit test location in tests/unit/EvictionPolicyStrategy
luis-gasparschroeder
requested changes
Jun 18, 2026
Comment on lines
+21
to
+32
| class LFUEvictionPolicy(EvictionPolicy): | ||
| """ | ||
| Least Frequently Used (LFU) eviction policy with LRU tie-breaking. | ||
|
|
||
| Tracks access_count per entry. Evicts lowest-frequency entries first. | ||
| Ties broken by last_accessed (oldest evicted first). | ||
|
|
||
| Args: | ||
| max_size (int): Maximum number of entries before eviction triggers. | ||
| watermark (float): Fraction of max_size that triggers eviction. | ||
| eviction_percentage (float): Fraction of max_size to evict per cycle. | ||
| """ |
Collaborator
There was a problem hiding this comment.
We already have an LRU policy in vcache/vcache_core/cache/eviction_policy/strategies/lru.py. Please extend that instead of implementing a new one.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
This PR adds LFUEvictionPolicy to vCache.
Motivation
Existing policies are recency-based. LFU retains high-value entries regardless of recency, improving hit rates on skewed workloads.
Changes
Tests
pytest tests/test_lfu_eviction_policy.py -v # 16 passed