How to determine if something is a member of an ordered set?

From what I see, there is no command for this, but I need something similar to the SISMEMBER command, but for ordered sets. Given that there is no command for this, what is the best way to determine if something is a member of an ordered set? Maybe ask for a member account with ZCORE, and if there is no rating, what is not the member?

+8
set html-lists redis
source share
1 answer

As you suggested, I would just use ZSCORE . If nil is returned, the requested item is not in the set. ZRANK will also work, but O (log n) and ZSCORE are 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) 
+12
source share

All Articles