HRANDFIELD

    When called with just the argument, return a random field from the hash value stored at key.

    If the provided count argument is positive, return an array of distinct fields. The array’s length is either count or the hash’s number of fields (HLEN), whichever is lower.

    The optional WITHVALUES modifier changes the reply so it includes the respective values of the randomly selected hash fields.

    Bulk string reply: without the additional count argument, the command returns a Bulk Reply with the randomly selected field, or nil when key does not exist.

    1. dragonfly> HMSET coin heads obverse tails reverse edge null
    2. "OK"
    3. dragonfly> HRANDFIELD coin
    4. "heads"
    5. dragonfly> HRANDFIELD coin
    6. dragonfly> HRANDFIELD coin -5 WITHVALUES
    7. 1) "edge"
    8. 3) "tails"
    9. 4) "reverse"
    10. 5) "heads"
    11. 6) "obverse"
    12. 7) "edge"
    13. 8) "null"
    14. 10) "obverse"

    When the count argument is a positive value this command behaves as follows:

    • No repeated fields are returned.
    • If count is bigger than the number of fields in the hash, the command will only return the whole hash without additional fields.
    • The order of fields in the reply is not truly random, so it is up to the client to shuffle them if needed.

    When the is a negative value, the behavior changes as follows:

    • Repeating fields are possible.
    • Exactly count fields, or an empty array if the hash is empty (non-existing key), are always returned.
    • Return