Skip to main content

Usage

Sets the specified fields to their respective values in the hash stored at key. This command overwrites any specified fields already existing in the hash.

Parameters

key
string
required
The key of the hash
fieldValueObject
Record<string, TData>
required
An object containing field-value pairs to set in the hash. Each key in the object represents a field name, and its value is the value to set.

Response

count
number
The number of fields that were added or updated in the hash.

Examples

Set multiple hash fields

Set a single field

Store complex objects

Store JSON data

See Also

  • HGET - Get a hash field value
  • HMSET - Set multiple hash fields (legacy)
  • HGETALL - Get all fields and values in a hash