From what I see there's no command for this, but I need something similar to the SISMEMBER command, but for ordered sets. Given that there's no command for this, what's the best way to determine if something is a member of an ordered set ? Maybe ask for the score of the member with ZCORE and if there's no score than there's no member ?
As you suggested, I would just use ZSCORE
. If nil is returned, then the requested member is not in the set. ZRANK
would also work, but it's O(log n) and ZSCORE
is O(1).
redis> zadd orderedset 1 key1
(integer) 1
redis> zadd orderedset 2 key2
(integer) 1
redis> zscore orderedset key1
"1"
redis> zscore orderedset badkey
(nil)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With