Skip to content
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

Merged
merged 8 commits into from
Jan 14, 2025

Conversation

Maayanshani25
Copy link
Collaborator

@Maayanshani25 Maayanshani25 commented Jan 1, 2025

Issue link

This Pull Request is linked to issue (URL): [/issues/2811]

Description

This pull Request is implemented the IFEQ option in the SET 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:

  • This Pull Request is related to one issue.
  • Commit message has a detailed description of what changed and why.
  • Tests are added or updated.
  • CHANGELOG.md and documentation files are updated.
  • Destination branch is correct - main or release
  • Create merge commit if merging release branch into main, squash otherwise.

@Maayanshani25 Maayanshani25 requested a review from a team as a code owner January 1, 2025 10:38
Maayan Shani and others added 2 commits January 1, 2025 10:41
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]>
Copy link
Collaborator

@Yury-Fridlyand Yury-Fridlyand left a 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

node/src/BaseClient.ts Outdated Show resolved Hide resolved
node/src/Commands.ts Outdated Show resolved Hide resolved
node/src/Commands.ts Outdated Show resolved Hide resolved
node/src/Commands.ts Outdated Show resolved Hide resolved
node/src/Commands.ts Outdated Show resolved Hide resolved
node/src/Commands.ts Outdated Show resolved Hide resolved
node/tests/SharedTests.ts Show resolved Hide resolved
@Yury-Fridlyand Yury-Fridlyand added the node Node.js wrapper label Jan 2, 2025
node/src/BaseClient.ts Show resolved Hide resolved
node/src/BaseClient.ts Outdated Show resolved Hide resolved
| {
/**
* `onlyIfDoesNotExist` - Only set the key if it does not already exist.
* Equivalent to `NX` in the Valkey API.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't like the usage of Equivalent to like we are creating something separate which has some interaction.
Let's find better ways to express it.
Maybe ֿsimple as:

* `onlyIfDoesNotExist` - Only set the key if it does not already exist.
* `NX` in the Valkey API.

Relevant to all the below options. I'm aware that it is not you who decided to use it, but still, I think it needs to be changed.

Copy link
Collaborator Author

@Maayanshani25 Maayanshani25 Jan 14, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

exists a lot of times. you want me to change all? (other commands also)

*
* // Example usage of set method with conditional option IFEQ
* 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".
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: value of "key" is confusing a bit.
Maybe the current value set to key?
Think about it.

Copy link
Collaborator Author

@Maayanshani25 Maayanshani25 Jan 14, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

But maybe the value haven't set yet so it will be null. For me it's clear enough but i will think of a better one

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Its not so important, but if you find something it will be great

node/src/Commands.ts Outdated Show resolved Hide resolved
* `onlyIfEqual` - Only set the key if the comparison value equals the key value.
* Equivalent to `IFEQ` in the Valkey API.
*/
conditionalSet: "onlyIfEqual";
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

IFEQ is short for "if equal", why do we need the "only"?
It is not aligned with the valkey naming, and I don't think it's to clarify something which is not clear.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it's like the other conditions onlyIfExists == NX and onlyIfDoesNotExist == EX. That is why i used only as a prefix

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

hmmm ok that's fair.

node/tests/SharedTests.ts Show resolved Hide resolved
Signed-off-by: Maayan Shani <[email protected]>
Copy link
Collaborator

@avifenesh avifenesh left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@Maayanshani25 Maayanshani25 merged commit 798dbef into valkey-io:main Jan 14, 2025
19 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
node Node.js wrapper
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants