Skip to main content

decide_cache_reuse

Function decide_cache_reuse 

Source
pub fn decide_cache_reuse(
    expected: Option<&KvCompatFingerprint>,
    stored: Option<&KvCompatFingerprint>,
    cache_is_empty: bool,
) -> CacheReuseDecision
Expand description

Decide whether a cache may be reused, given the authoritative expected identity (if any), the stamp currently on the cache (if any), and whether the cache provably carries no KV.

Decision matrix (every non-Reuse outcome discards KV — fail-closed):

expectedstoredemptydecision
Some(e)Some(s)*e == s ? Reuse : DiscardAndRecompute
Some(_)NonetrueStampFresh
Some(_)NonefalseDiscardAndRecompute
None**DiscardAndRecompute

The unstamped-but-populated and no-authoritative-identity rows are the fail-closed guards: a cache we cannot authoritatively attribute is never reused, only recomputed.