ZRANDMEMBER
Since 1.1.0Sorted sets
Syntax
ZRANDMEMBER key [count [WITHSCORES]]Returns members of the sorted set at key, picked at random, without removing them.
Reply
- Without
count: a member, ornilif the key does not exist. - With a positive
count: up tocountdifferent members; a negativecountreturns exactly-count, which may repeat.WITHSCORESgives each score.
Examples
> ZADD rr 1 a 2 b 3 c
(integer) 3
> ZRANDMEMBER rr 2 WITHSCORES
1) "b"
2) "2"
3) "a"
4) "1"