CacheKit Docs

High-performance cache policies and supporting data structures.

View the Project on GitHub OxidizeLabs/cachekit

Cache Replacement Policies

This document summarizes common cache replacement (eviction) policies, their tradeoffs, and when to use (or avoid) each. It’s written as a practical companion to Design overview.

Implementation notes live in the per-policy docs and the policy data structures.

Terminology used below:

How This Doc Is Organized

How To Choose (Quick Guidance)

These recommendations mirror the latest benchmark guide in Benchmarks. Results depend on workload shape, cache size, and access distribution.

Pick based on workload first:

If you can only implement one “general purpose” policy for mixed workloads, S3-FIFO or LRU are the strongest defaults in current benchmarks, with 2Q as a good alternative when scans are common.

Policy Catalog (Summaries)

Implemented Policies (CacheKit)

Policy Summary Doc
LRU Strong default for temporal locality LRU doc
MRU Evicts most recent (niche: cyclic patterns) MRU doc
SLRU Segmented LRU with probation/protected SLRU doc
LFU Frequency-driven, stable hot sets LFU doc
Heap-LFU LFU with heap eviction Heap-LFU doc
MFU Evicts highest frequency (niche/baseline) MFU doc
LRU-K Scan-resistant recency LRU-K doc
2Q Probation + protected queues 2Q doc
ARC Adaptive recency/frequency balance ARC doc
CAR ARC-like with Clock (lower hit overhead) CAR doc
FIFO Simple insertion-order (oldest first) FIFO doc
LIFO Stack-based (newest first) LIFO doc
Clock Approximate LRU Clock doc
Clock-PRO Scan-resistant Clock variant Clock-PRO doc
NRU Coarse recency tracking NRU doc
S3-FIFO Scan-resistant FIFO S3-FIFO doc
Random Baseline: uniform random eviction Random doc

Roadmap Policies (Planned)

See Policy roadmap for upcoming policies (LIRS, GDSF, TinyLFU/W-TinyLFU, etc.).

Implemented Policy Summaries (Short)

For broader policy taxonomy (OPT, ARC, CAR, LIRS, Random, etc.), use the Policy roadmap and reference material below.

Practical Tradeoffs (What Changes In Real Systems)

When To Use / Not Use (Rules Of Thumb)

Quick Decision Flow

See Also

Reference Material