CacheKit Docs

High-performance cache policies and supporting data structures.

View the Project on GitHub OxidizeLabs/cachekit

MFU operational spec

Spec maturity: reference

Executable oracle: tests/abstract_models/exact/mfu.rs (MfuModel); independent reference: reference/mfu.rs (NaiveMfuModel).

Most Frequently Used cache replacement: evict the key with maximum frequency when space is needed.

State

Variable Type Meaning
freq Map<K, ℕ> Live frequency per resident key
heap max-heap with sequence numbers Stale entries possible
capacity usize Maximum resident count

Init

Observables

Observable Definition
resident Keys in freq
peek_victim Max frequency; highest sequence number at ties (newest heap entry)
hit MustHit / MustMiss

Operations

Insert(k)

  1. If k ∈ resident: increment frequency.
  2. Else if full: evict max-frequency victim (newest heap entry at ties), record evicted_on_insert.
  3. Insert at frequency 1.

Get(k) / Peek(k)

Remove(k) / EvictOne

Tie-breaks

Harness notes

References