Hash

HSET

Write one or more fields to a hash.

Arguments

keybodystrrequired

The key of the hash.

fieldbodystr

Field to set

valuebodystr

Value to set

valuesbodyDict[str, Any]

An object of fields and their values.

Response

intrequired

The number of fields that were added.

Single
# Set a single fieldassert redis.hset("myhash", "field1", "Hello") == 1
Multiple
# Set multiple fieldsassert redis.hset("myhash", values={  "field1": "Hello",  "field2": "World"}) == 2
Loading search…