High-performance cache policies and supporting data structures.
Feature: policy-lfu
Evict the entry with the lowest access frequency; break ties by recency (common) or arbitrarily.
The typical O(1) LFU design is:
HashMap<K, EntryId> to locate entriesfreq, plus pointers for an intrusive list inside its frequency bucketHashMap<freq, BucketList> (or Vec<BucketList> with bounded freq) storing LRU order within each frequencymin_freq tracking the smallest frequency currently presentIn cachekit, src/policy/lfu.rs implements LFU with O(1) eviction based on bucket + min_freq.
get(key)freq.min_freq, increment min_freq.insert(key, value)min_freq bucket (usually the LRU within that bucket).freq = 1 and set min_freq = 1.pop_lfu()min_freq bucket; if it becomes empty, advance min_freq.Pure LFU can keep “once-hot” items forever. To avoid this, add one of:
score = freq / f(age) (more complex)See lfu-aging.md for common patterns.