SRANDMEMBER
Since 1.1.0Sets
Syntax
SRANDMEMBER key [count]Returns members of the 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. - With a negative
count: exactly-countmembers, which may repeat.
Examples
> SADD r 1 2 3
(integer) 3
> SRANDMEMBER r 2
1) "2"
2) "1"
> SRANDMEMBER r -5
1) "3"
2) "3"
3) "3"
4) "2"
5) "3"