-
Notifications
You must be signed in to change notification settings - Fork 65
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
SET IFEQ command implemented in node + tests #2909
base: main
Are you sure you want to change the base?
Conversation
Signed-off-by: Maayan Shani <[email protected]> Signed-off-by: Maayan Shani <[email protected]>
Signed-off-by: Maayan Shani <[email protected]> Signed-off-by: Maayan Shani <[email protected]>
3ac0f80
to
a7300c5
Compare
Signed-off-by: Maayan Shani <[email protected]>
Signed-off-by: Maayan Shani <[email protected]>
041a662
to
febef71
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please add a changelog
@@ -1473,7 +1473,7 @@ export class BaseClient { | |||
* @param value - The value to store with the given key. | |||
* @param options - (Optional) See {@link SetOptions} and {@link DecoderOption}. | |||
* @returns - If the value is successfully set, return OK. | |||
* If value isn't set because of `onlyIfExists` or `onlyIfDoesNotExist` conditions, return null. | |||
* If value isn't set because of `onlyIfExists` or `onlyIfDoesNotExist` or `onlyIfEqual`conditions, return null. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
* If value isn't set because of `onlyIfExists` or `onlyIfDoesNotExist` or `onlyIfEqual`conditions, return null. | |
* If value isn't set because of `onlyIfExists` or `onlyIfDoesNotExist` or `onlyIfEqual` conditions, return `null`. |
* 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 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
* it already exist. Equivalent to `EX` in the Valkey API. `onlyIfEqual` - Only set the | |
* it already exists. Equivalent to `EX` in the Valkey API. `onlyIfEqual` - Only set the |
} else if (options.conditionalSet === "onlyIfEqual") { | ||
args.push("IFEQ"); | ||
|
||
if (options.comparisonValue != undefined) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if (options.comparisonValue != undefined) { | |
if (options.comparisonValue) { |
conditionalSet?: "onlyIfExists" | "onlyIfDoesNotExist"; | ||
conditionalSet?: "onlyIfExists" | "onlyIfDoesNotExist" | "onlyIfEqual"; | ||
/** | ||
* If onlyIfEqual is set, the value to compare the existing value with. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
* If onlyIfEqual is set, the value to compare the existing value with. | |
* If `onlyIfEqual` is set, the value to compare the existing value with. |
* 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. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I propose to add line breaks for better readability.
onlyIfDoesNotExist
- ...
onlyIfExists
- ...
And move last two lines to set
docs.
/** | ||
* If onlyIfEqual is set, the value to compare the existing value with. | ||
*/ | ||
comparisonValue?: GlideString; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You can do
SetOptions = ({
conditionalSet?: "onlyIfExists" | "onlyIfDoesNotExist";
} | {
conditionalSet: "onlyIfEqual";
comparisonValue: GlideString;
} & {
...
}
)
and then remove value check on lines 179-184
@@ -8260,18 +8319,55 @@ export function runBaseTests(config: { | |||
|
|||
expect(setRes).toBeDefined(); | |||
} | |||
|
|||
// onlyIfEqual tests | |||
if (!cluster.checkIfServerVersionLessThan("8.1.0")) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You already have a version check on line 8365. This one is always true.
Issue link
This Pull Request is linked to issue (URL): [/issues/2811]
Description
This pull Request is implemented the
IFEQ
option in theSET
commamnd. Tests were added to the shared tests, and docstring to the command and the related methods and structures.Checklist
Before submitting the PR make sure the following are checked: