SISMEMBER
- Usage:
-
SISMEMBER key member [ XX ]
- Complexity:
- O(1)
- Since:
- 1.0.0
- ACL Categories:
- @fast, @read, @set
Returns if member is a member of the set stored at key.
By default, a missing key is treated as an empty set, so SISMEMBER returns 0
both when the key does not exist and when the set does not contain member.
The XX option tells these two cases apart: with XX,
SISMEMBER returns -1 when the key does not exist.
Options#
XX-- Return-1instead of0whenkeydoes not exist.
Reply#
One of the following:
- Integer:
1if the element is a member of the set. - Integer:
0if the element is not a member of the set, or when the key does not exist andXXwas not given. - Integer:
-1if the key does not exist andXXwas given.
Examples#
127.0.0.1:6379> SADD myset "one"
(integer) 1
127.0.0.1:6379> SISMEMBER myset "one"
(integer) 1
127.0.0.1:6379> SISMEMBER myset "two"
(integer) 0
127.0.0.1:6379> SISMEMBER myset "two" XX
(integer) 0
127.0.0.1:6379> SISMEMBER nosuchset "one"
(integer) 0
127.0.0.1:6379> SISMEMBER nosuchset "one" XX
(integer) -1
History#
| Version | Change |
|---|---|
| 9.2.0 | Added the |