diff --git a/node/src/BaseClient.ts b/node/src/BaseClient.ts index 30d58a976f..2e0fbfc74c 100644 --- a/node/src/BaseClient.ts +++ b/node/src/BaseClient.ts @@ -1495,8 +1495,8 @@ export class BaseClient { * console.log(result4); // Output: 'new_value' - Value wasn't modified back to being "value" because of "NX" flag. * * // Example usage of set method with conditional option IFEQ - * const result5 = await client.set("key", "ifeq_value", {conditionalSet: "onlyIfEqual", providedValue: "new_value"); - * console.log(result5); // Output: 'OK' - Set "ifeq_value" to "key" only if providedValue is equal to the value of "key". + * const result5 = await client.set("key", "ifeq_value", {conditionalSet: "onlyIfEqual", comparisonValue: "new_value"); + * console.log(result5); // Output: 'OK' - Set "ifeq_value" to "key" only if comparisonValue is equal to the value of "key". * ``` */ public async set( diff --git a/node/src/Commands.ts b/node/src/Commands.ts index 8d6952057d..b32a850adf 100644 --- a/node/src/Commands.ts +++ b/node/src/Commands.ts @@ -128,15 +128,16 @@ export interface SetOptions { /** * `onlyIfDoesNotExist` - Only set the key if it does not already exist. * Equivalent to `NX` in the Valkey API. `onlyIfExists` - Only set the key if - * it already exist. Equivalent to `EX` in the Valkey API. if `conditional` is - * not set the value will be set regardless of prior value existence. If value - * isn't set because of the condition, return null. + * it already exist. Equivalent to `EX` in the Valkey API. `onlyIfEqual` - Only set the + * key if the comparison value equals to the key value. Equivalent to `IFEQ` in the Valkey API. + * if `conditional` is not set the value will be set regardless of prior value existence. + * If value isn't set because of the condition, return null. */ conditionalSet?: "onlyIfExists" | "onlyIfDoesNotExist" | "onlyIfEqual"; /** * If onlyIfEqual is set, the value to compare the existing value with. */ - providedValue?: GlideString; + comparisonValue?: GlideString; /** * Return the old string stored at key, or nil if key did not exist. An error * is returned and SET aborted if the value stored at key is not a string. @@ -175,11 +176,11 @@ export function createSet( } else if (options.conditionalSet === "onlyIfEqual") { args.push("IFEQ"); - if (options.providedValue != undefined) { - args.push(options.providedValue); + if (options.comparisonValue != undefined) { + args.push(options.comparisonValue); } else { throw new Error( - "The 'providedValue' option must be set when using 'onlyIfEqual'", + "The 'comparisonValue' option must be set when using 'onlyIfEqual'", ); } } diff --git a/node/tests/SharedTests.ts b/node/tests/SharedTests.ts index bd78de8085..162eea4bf3 100644 --- a/node/tests/SharedTests.ts +++ b/node/tests/SharedTests.ts @@ -8147,14 +8147,14 @@ export function runBaseTests(config: { // Attempt to set with a non-matching value (should fail -> return null) const conditionalSetFailResponse = await client.set(key, newValue, { conditionalSet: "onlyIfEqual", - providedValue: newValue, + comparisonValue: newValue, }); expect(conditionalSetFailResponse).toEqual(null); // Attempt to set with a matching value (should succeed -> return OK) const conditionalSetSuccessResponse = await client.set(key, newValue, { conditionalSet: "onlyIfEqual", - providedValue: initialValue, + comparisonValue: initialValue, }); expect(conditionalSetSuccessResponse).toEqual("OK"); @@ -8246,7 +8246,7 @@ export function runBaseTests(config: { count: Math.floor(Date.now() / 1000) + 1, }, conditionalSet: "onlyIfEqual", - providedValue: initialValue, + comparisonValue: initialValue, returnOldValue: true, }); // initialValue should be get from the key @@ -8338,7 +8338,7 @@ export function runBaseTests(config: { count: number; }, conditionalSet: "onlyIfEqual", - providedValue: value, // Ensure it matches the current key's value + comparisonValue: value, // Ensure it matches the current key's value }); if (setRes) { diff --git a/python/python/glide/async_commands/core.py b/python/python/glide/async_commands/core.py index 880bf29642..85c361f7d3 100644 --- a/python/python/glide/async_commands/core.py +++ b/python/python/glide/async_commands/core.py @@ -73,12 +73,10 @@ class ConditionalChange(Enum): A condition to the `SET`, `ZADD` and `GEOADD` commands. - ONLY_IF_EXISTS - Only update key / elements that already exist. Equivalent to `XX` in the Valkey API. - ONLY_IF_DOES_NOT_EXIST - Only set key / add elements that does not already exist. Equivalent to `NX` in the Valkey API. - - ONLY_IF_EQUAL - Only update key if the provided value is equal to the old value. Equivalent to `IFEQ` in the Valkey API. """ ONLY_IF_EXISTS = "XX" ONLY_IF_DOES_NOT_EXIST = "NX" - ONLY_IF_EQUAL = "IFEQ" class ExpiryType(Enum):