High-performance cache policies and supporting data structures.
Spec maturity: reference
Executable oracle:
tests/abstract_models/exact/mru.rs(MruModel); independent reference:reference/mru.rs(NaiveMruModel).
Most Recently Used cache replacement: evict the most recently used key (head of list) when space is needed.
| Variable | Type | Meaning |
|---|---|---|
order |
Seq<K> |
Front = MRU (eviction victim); back = LRU |
capacity |
usize |
Maximum resident count |
order = ⟨⟩capacity = C| Observable | Definition |
|---|---|
resident |
Keys in order |
peek_victim |
Not asserted in harness (no VictimInspectable on impl) |
hit |
MustHit / MustMiss from membership |
Insert(k)k ∈ resident: no-op for ordering (value update only in implementation).|resident| ≥ capacity: evict front (MRU), record evicted_on_insert.k at front.Get(k) / GetMut(k)hit accordingly.Peek(k)hit from membership. No promotion.Touch(k)Get).Remove(k)k from order if present.EvictOnevictim = Exact(front).Op mappingOp |
Cache API | Side effects |
|---|---|---|
Insert(k) |
insert(k, v) |
Promote or insert/evict MRU |
Get(k) |
get(k) |
Promote on hit |
Peek(k) |
peek(k) |
No promotion |
GetMut(k) |
— | No-op in adapter |
Touch(k) |
touch(k) |
Promote on hit |
Remove(k) |
remove(k) |
Remove |
EvictOne |
evict_one() |
Evict MRU |