CacheKit Docs

High-performance cache policies and supporting data structures.

View the Project on GitHub OxidizeLabs/cachekit

SLRU (Segmented LRU)

Feature: policy-slru

Goal

Reduce scan pollution by separating “probationary” entries from “protected” entries.

Core Idea

Maintain two LRU lists:

Rules (typical):

Core Data Structures

In cachekit, src/policy/slru.rs uses:

Operations

get(key)

insert(key, value)

Eviction Logic

Complexity & Overhead

Tuning

Requires choosing sizes for probationary/protected partitions:

Concurrency Notes

Like plain LRU, SLRU mutates shared metadata on every hit:

cachekit’s SlruCore is designed for single-threaded use or external synchronization.

Safety / Invariants (Rust)

Uses intrusive pointers (NonNull<Node<_>>):

When to Use

Comparison with Other Policies

Policy Segments Adaptivity Complexity
LRU 1 None Low
SLRU 2 None Medium
2Q 2 + ghost Some Medium
ARC 2 + 2 ghost Full High

SLRU sits between plain LRU and more complex adaptive policies like 2Q or ARC.

References