Skip to main content

Module policy

Module policy 

Source
Expand description

Pluggable cache admission and eviction policy traits (ADR 040).

The engine owns the store and every safety exemption (pins, probe-holds, deny/takedown). A policy is a pure decision function fed observations: it ranks eligible candidates or classifies an admission, and never reaches into the store.

Re-exports§

pub use lru::AlwaysAdmit;
pub use lru::LruEviction;
pub use tinylfu::ProbationAdmission;
pub use tinylfu::TinyLfuEstimator;
pub use tinylfu::TinyLfuEviction;

Modules§

lru
Behavior-preserving default policies: recency eviction, unconditional admit.
sketch
Count-min frequency sketch keyed directly on BLAKE3 hashes (ADR 040).
tinylfu
W-TinyLFU estimator + policies (filled in Stage B, Tasks 5-7).

Structs§

AdmissionContext
Inputs available to an admission decision.
EvictionContext
Everything a policy needs to plan one eviction sweep. The engine assembles it and never interprets the policy’s semantics — candidates is already stripped of pins and probe-holds (a deny-listed hash stays a candidate even when pinned: deny wins over pin), and segments is the generic hash -> Segment membership the engine tracks with no meaning attached.
EvictionPlan
The single sweep-time decision: what leaves, and what graduates to a new segment. LruEviction returns promote empty.

Enums§

AdmissionDecision
A policy’s admission verdict for a miss about to be served.
Segment
Where a freshly admitted blob is stored.

Traits§

AdmissionPolicy
Decides whether a miss about to be served is worth keeping, and where.
EvictionPolicy
Decides what the engine releases when the store is over its target.
FrequencyEstimator
Decayed frequency estimate shared by admission and eviction.