zrandmember
ZRANDMEMBER
Apply for Redis Developer Course
|
Redis Regular Inspection / Technical Support
|
Redis Enterprise Server
|
|---|
Return random members
Example
| Command> | zadd mycity 10 Seoul 20 Busan 30 Daegu 40 Incheon 50 Gwangju 60 Gyeonggi |
| Result> | 6 |
| Command> | zrandmember mycity |
| Result> | Gyeonggi |
Return multiple members: count
Use the count option to return multiple members.
+count returns distinct members.
If count is larger than the set size, all members are returned.
-count may return duplicate members.
If count is larger than the set size, count members are returned (with duplicates).
The withscores option can be used only with count.
Example
| Command> | zrandmember mycity 3 |
| Result> |
1) "Gyeonggi" 2) "Seoul" 3) "Daegu" |
| Command> | zrandmember mycity -3 |
| Result> |
1) "Incheon" 2) "Incheon" 3) "Seoul" |
Syntax
ZRANDMEMBER key [count [withscores]]
- Available since version 6.2.0.
- Time complexity is O(N). N is the number of returned values.
| << ZISMEMBER | ZRANDMEMBER | HASHES Intro >> |
|---|
Email
답글이 올라오면 이메일로 알려드리겠습니다.
