High-performance cache policies and supporting data structures.
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.
| 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 |
tick = 0, capacity = C, k given.| 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 |
Insert(k) / Get(k) / Peek(k) / Touch(k)history; increment tick on promoting ops.k from cold to hot (MRU in hot).Remove(k) / EvictOnecold deque).Op mappingOp |
Traits asserted |
|---|---|
| All | HistoryTracking, EvictingCache |
GetMut: no-op in adapter.