hrandfield
HRANDFIELD
Apply for Redis Developer Course
|
Redis Regular Inspection / Technical Support
|
Redis Enterprise Server
|
|---|
Get a random field
Example
| Command> | hmset myhash f1 v1 f2 v2 f3 v3 f4 v4 f5 v5 f6 v6 |
| Result> | OK |
| Command> | hrandfield myhash |
| Result> | f3 |
Get multiple fields: count
To get multiple fields, use the count option.
+count returns fields without duplicates.
If you specify a count larger than the number of fields, it returns as many fields as exist.
-count returns fields with duplicates allowed.
If you specify a count larger than the number of fields, it returns the specified count.
The withvalues option can be used only when count is used.
Example
| Command> | hrandfield myhash 3 |
| Result> |
1) "f6" 2) "f5" 3) "f3" |
| Command> | hrandfield myhash -3 |
| Result> |
1) "f2" 2) "f4" 3) "f4" |
Syntax
HRANDFIELD key [count [WITHVALUES]]
- Available since version 6.2.0.
- Time complexity is O(N). N is the number of returned fields.
| << HSCAN | HRANDFIELD | STREAMS Introduction >> |
|---|
Email
답글이 올라오면 이메일로 알려드리겠습니다.
