CacheKit Docs

High-performance cache policies and supporting data structures.

View the Project on GitHub OxidizeLabs/cachekit

LFU (Least Frequently Used)

Feature: policy-lfu

Goal

Evict the entry with the lowest access frequency; break ties by recency (common) or arbitrarily.

Common Production Approach: Bucketed LFU (O(1))

The typical O(1) LFU design is:

In cachekit, src/policy/lfu.rs implements LFU with O(1) eviction based on bucket + min_freq.

Operations

get(key)

insert(key, value)

pop_lfu()

Complexity & Overhead

Aging / Decay (Important)

Pure LFU can keep “once-hot” items forever. To avoid this, add one of:

See lfu-aging.md for common patterns.

References