Repository navigation
feat(cache): serve stale values to plain reads that allow them - #591
Merged
Merged
Conversation
cosmin-staicu
requested review from
alinahornet,
florin-munteanu-uipath,
litheon,
lucianaparaschivei and
razvalex
as code owners
November 30, 2026 15:48
|
🔎 Maintainer heads-up: automated triage flagged this PR as potentially material, so it may need a signed CLA in addition to the DCO sign-off. Strong signals
Other signals
This is advisory only — the bot does not decide. Please judge against the CLA criteria (material, product-critical, patent-sensitive, corporate contributor, broad commercial use). Note that thresholds can be gamed by splitting PRs, so use your judgement.
|
cosmin-staicu
force-pushed
the
feat/fail-safe-stale-reads
branch
from
November 30, 2026 15:50
a6a60ca to
3fb0025
Compare
cosmin-staicu
force-pushed
the
feat/fail-safe-stale-reads
branch
from
November 30, 2026 16:10
3fb0025 to
a28d645
Compare
A new policy option, FailSafeAllowStaleReads, lets single-key GetAsync and GetCacheEntryAsync return an expired value. GetCacheEntryAsync marks such an entry with the new ICacheEntry.IsStale member, which defaults to false. On InMemory the read returns the node's kept value once its deadline has passed. A value the local tier evicted early is not stale before its deadline. On Redis-only and layered caches the read returns the expired copy that a read-only transaction on the master confirmed, within the writer's window and the caller's own stale age on the monotonic clock. A layered cache serves it only when it hears peer events and shares the Redis tier's TimeProvider. Inner single-key reads, the opt-in stale copy read included, never carry the option. When a peer change or lost events are heard while a shared read runs, no caller of that read gets the copy. Callers without the option get no confirm read and no extra allocation. Validation refuses the option without FailSafeEnabled, and without FailSafeDistributedEnabled on a provider with a Redis tier. A named policy that turns fail-safe off may inherit the option, but may not set it. A zero FailSafeMaxStaleAge is refused when it would set the Redis window, that is with FailSafeDistributedEnabled on and FailSafeDistributedMaxStaleAge unset. Stale hits are counted per source, and the guide, settings reference and changelog describe the option, its read cost and its limits. Signed-off-by: Cosmin Staicu <cosmin.staicu@uipath.com>
cosmin-staicu
force-pushed
the
feat/fail-safe-stale-reads
branch
from
November 30, 2026 16:24
a28d645 to
315bb92
Compare
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.



Summary
A new policy option,
FailSafeAllowStaleReads, lets single-keyGetAsyncandGetCacheEntryAsyncreturn an expired value. Stacked on #587; this PR shows only its own layer.Changes
GetCacheEntryAsyncmarks a stale entry with the newICacheEntry.IsStalemember. It is a default member that returns false, so existing implementers do not break.TimeProvider. If a peer change or lost events are heard while a shared read runs, no caller of that read gets the copy.FailSafeEnabled, and withoutFailSafeDistributedEnabledon a provider with a Redis tier. A named policy that turns fail-safe off may inherit the option but may not set it. A zeroFailSafeMaxStaleAgeis refused when it would set the Redis window.Tests
Release, net10.0 and net8.0, with Redis 7.4 and 6.2: stale-read InMemory, Redis-only and layered tests, peer and validation tests, fail-safe classes, allocation pins (no pinned constant changed), PluginContract and Config.