Support 8.4 CAS/CAD (IF*) operations #2978
Merged
+1,077
−9
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.
8.4 adds
SET key value ... [IFEQ|IFNE|IFDEQ|IFDNE hash-or-value]modifiers for check-and-set (CAS) semanticsDEL key [IFEQ|IFNE|IFDEQ|IFDNE hash-or-value]modifiers for check-and-delete (CAD) semanticsDIGEST keyfor fetching the server-computed hash of a given string valueIFEQ/IFNEare value equality / non-equality checks; the key is interpreted as a string and checked for full equality against the supplied value.IFDEQ/IFDNEare digest (hash) equality / non-equality checks; the key is interpreted as a string and the digest computed, and the digest is checked for equality against the supplied value. In the case of a test failure, the operation is a no-op and a nil reply is provided, the same as for aXX/NXfailure.The key can also be computed local via xxhash3 (64-bit mode).
This PR:
ValueConditionabstraction, which supersedesWhen(and supports all legacyWhenuse-cases)ValueCondition(this can also be negated, to create an "IFDNE"ValueCondition)LockExtend[Async]andLockRelease[Async]to prefer CAS/CAD overMULTI/EXECwhen available[P]EXPIRE ... IFEQ, so we useSET key value EX ttl IFEQ value- mildly suboptimal, but not enough to be a problemValueConditionAPI surfaceNote that
System.IO.Hashingis consumed to supplyXxHash3- this is a new package dependency, with ns20, net462, net8 and net9 TFMs.Note: is is planned to combine this work with
MSETEX(also 8.4), and use the new expiration abstraction in the new APIs. This means that the current API withTimeSpan? expiryis not "final" - a combined API will allow all of (nothing),EX,PX,EXAT,PXAT,KEEPTTLandPERSISTto be overlapped on a single API, similar to howValueConditionworks here.Note: CI may fail horribly right now; the 8.4 RC1 ref'd by CI update has glitches that are already fixed. This will be updated (8.4 RC1 is likely to be re-released; it was effectively an internal preview)
Note that all 8.4 features are going to be marked
[Experimental]for now, since 8.4 is an RC. This is[SER002]in the API defs below.The
ValueConditionAPI is worth explicit mention; summary: