redis.hset("myhash", values={
    "field1": "Hello",
    "field2": "World"
})

assert redis.hrandfield("myhash") in ["field1", "field2"]

Arguments

key
str
required
The key of the hash.
count
int
Optionally return more than one field.
withvalues
boolean
Return the values of the fields as well.

Response

An object containing the fields and their values.
redis.hset("myhash", values={
    "field1": "Hello",
    "field2": "World"
})

assert redis.hrandfield("myhash") in ["field1", "field2"]