You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Remove Remove() from ValidatingCache API and replace eager-cleanup with a background sweep #4727
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
Remove Remove() from the ValidatingCache API
Remove the two call sites that use it (Terminate Phase 2, DecorateSession's !updated path)
Add a background sweep that proactively runs the cache's built-in checkSession function to evict invalid entries, addressing the eager-cleanup concern without widening the API surface
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
Activity
yrobla commentedon Apr 13, 2026
implemented on same patch