CacheKit Docs

High-performance cache policies and supporting data structures.

View the Project on GitHub OxidizeLabs/cachekit

LRU-K operational spec

Spec maturity: reference

Executable oracle: tests/abstract_models/exact/lru_k.rs (LruKModel); independent reference: reference/lru_k.rs (NaiveLruKModel).

LRU-K: track last K access times per key; evict from cold segment using LRU; promote to hot after K-th access.

State

Variable Type Meaning
cold Seq<K> LRU-ordered cold segment (back = victim)
hot Seq<K> LRU-ordered hot segment
segment Map<K, {Cold, Hot}> Per-key segment
history Map<K, Seq<time>> Last K access timestamps (step counter)
tick Monotonic step counter
k usize History depth (parameter)
capacity usize Maximum resident count

Init

Observables

Observable Definition
resident Keys in segment
peek_victim Back of cold (LRU among cold keys)
history(k) Last K access times for k
hit MustHit / MustMiss

Operations

Insert(k) / Get(k) / Peek(k) / Touch(k)

Remove(k) / EvictOne

Tie-breaks

Harness Op mapping

Op Traits asserted
All HistoryTracking, EvictingCache

GetMut: no-op in adapter.

References