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

Node: added sismember command. #1083

Merged
merged 1 commit into from
Mar 7, 2024
Merged

Conversation

adanWattad
Copy link
Contributor

Issue #, if available:

Description of changes:

By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.

CHANGELOG.md Outdated
@@ -2,7 +2,7 @@

* Node: Allow routing Cluster requests by address. ([#1021](https://github.com/aws/glide-for-redis/pull/1021))
* Python: Added HSETNX command. ([#954](https://github.com/aws/glide-for-redis/pull/954))
* Python: Added SISMEMBER command ([#971](https://github.com/aws/glide-for-redis/pull/971))
* Python, Node: Added SISMEMBER command ([#971](https://github.com/aws/glide-for-redis/pull/971), [#1083](https://github.com/aws/glide-for-redis/pull/1083))
Copy link
Collaborator

Choose a reason for hiding this comment

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

Python- it's actually 972

/** Returns if `member` is a member of the set stored at `key`.
* See https://redis.io/commands/sismember/ for more details.
*
* @param key - The key to return the number of its members.
Copy link
Collaborator

Choose a reason for hiding this comment

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

key - The key of the set.

*
* @param key - The key to return the number of its members.
* @param member - The member to check for existence in the set.
* @returns true if the member exists in the set, false otherwise.
Copy link
Collaborator

Choose a reason for hiding this comment

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

true ... false

* @param key - The key to return the number of its members.
* @param member - The member to check for existence in the set.
* @returns true if the member exists in the set, false otherwise.
* If `key` doesn't exist, it is treated as an empty set and the command returns false.
Copy link
Collaborator

Choose a reason for hiding this comment

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

false

@@ -633,6 +634,19 @@ export class BaseTransaction<T extends BaseTransaction<T>> {
return this.addAndReturn(createSCard(key));
}

/** Returns if `member` is a member of the set stored at `key`.
Copy link
Collaborator

Choose a reason for hiding this comment

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

same

@@ -824,6 +825,18 @@ export class BaseClient {
return this.createWritePromise(createSCard(key));
}

/** Returns if `member` is a member of the set stored at `key`.
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
/** Returns if `member` is a member of the set stored at `key`.
/** Returns whether `member` is a member of the set stored at `key`.

* @param member - The member to check for existence in the set.
* @returns true if the member exists in the set, false otherwise.
* If `key` doesn't exist, it is treated as an empty set and the command returns false.
*/
Copy link
Collaborator

Choose a reason for hiding this comment

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

What if key exists, but it is not a set?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It will throw an error, but we decided not to document this error (see other set commands).

await client.sismember(key, "nonExistingMember")
).toEqual(false);
expect(
await client.sismember("nonExistingKey", "member1")
Copy link
Collaborator

Choose a reason for hiding this comment

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

Add a test when key exists, but it is not a set

@adanWattad adanWattad merged commit 0f7db1a into valkey-io:main Mar 7, 2024
6 checks passed
@adanWattad adanWattad deleted the node/sismember branch March 7, 2024 13:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants