feat: enable shadowing for untracked caches - #122
Merged
Conversation
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
Motivation
Shadowing was gated on
trackForInvalidation: true, so an otherwise valid untracked Redis policy with a nonzeroshadow.rampdid nothing. That prevented teams from validating and warming ordinary Redis keys before increasing their serving ramp.The intended contract is:
The detached path never serves the caller. When remote serving is ramped down, it reuses the caller's already-running, successfully accepted source result instead of calling the loader again.
Architecture and correctness
This reuses the existing mechanisms rather than adding another public concept:
scheduleShadowValidationno longer rejects untracked keys.The key's established consistency mode remains authoritative:
The initial clean-miss read and detached fill are not atomic. An untracked fill can overwrite a newer concurrent value and remain until expiry; the README now states that boundary explicitly. Existing tracked invalidation fencing is unchanged.
Compatibility and rollout
Calls with omitted
shadowconfiguration orshadow.ramp: 0are unchanged.This is an intentional behavior change for untracked keys that already have all of the following:
shadow.rampmetrics.shadowValidationhookThose keys now generate the opted-in source/Redis validation traffic and may fill clean misses. Deployments that configured a nonzero shadow ramp while relying on the previous tracked-only eligibility rule should set it to
0before upgrading if they do not want that work.Test coverage
The added coverage proves:
Validation
Run with Node 22.22.0:
corepack pnpm check— 408 unit tests, coverage thresholds, typecheck, build/declarations, and packed ESM/CJS consumerscorepack pnpm test:integration— 101 Redis 6.2 / Valkey 8 integration tests across node-redis and GLIDEcorepack pnpm benchmark:request-local— all 10 semantic scenarios passedcorepack pnpm audit --prod --audit-level high— no known production vulnerabilitiesgit diff --check