Context
Raised as a suggestion during review (discussed with @JAORMX).
ValidatingCache.Remove was added to support two call sites:
Terminate Phase 2 — evicts the entry after session teardown
DecorateSession's !updated path — evicts a stale entry after a failed update
Both are prompt-cleanup optimizations. In both cases the cache self-heals on the next Get via checkSession, so the explicit Remove calls are not correctness-critical.
Problem
Exposing Remove invites callers to manage cache state imperatively rather than relying on the liveness invariant, which is the whole point of the ValidatingCache design. Widening the API surface in this way makes it easier for future contributors to bypass the invariant by manually evicting entries instead of trusting the check function.
Suggestion
The background sweep is a small addition and achieves the same eager-eviction goal while keeping cache lifecycle management internal to the cache itself.
References
- PR where
Remove was introduced and discussed with @JAORMX
Context
Raised as a suggestion during review (discussed with @JAORMX).
ValidatingCache.Removewas added to support two call sites:TerminatePhase 2 — evicts the entry after session teardownDecorateSession's!updatedpath — evicts a stale entry after a failed updateBoth are prompt-cleanup optimizations. In both cases the cache self-heals on the next
GetviacheckSession, so the explicitRemovecalls are not correctness-critical.Problem
Exposing
Removeinvites callers to manage cache state imperatively rather than relying on the liveness invariant, which is the whole point of theValidatingCachedesign. Widening the API surface in this way makes it easier for future contributors to bypass the invariant by manually evicting entries instead of trusting the check function.Suggestion
Remove()from theValidatingCacheAPITerminatePhase 2,DecorateSession's!updatedpath)checkSessionfunction to evict invalid entries, addressing the eager-cleanup concern without widening the API surfaceThe background sweep is a small addition and achieves the same eager-eviction goal while keeping cache lifecycle management internal to the cache itself.
References
Removewas introduced and discussed with @JAORMX