Redis HMSET is a command that sets multiple fields of a hash in Redis. It is used to add or update multiple key-value pairs to a hash data structure at once.
The syntax for Redis HMSET command is:
HMSET key field1 value1 [field2 value2 ...]
where key
is the name of the hash, field
is the key within the hash, and value
is the associated value for the key.
For example, the following command sets the values for three fields in a hash named “user”:
HMSET user id 123 name john age 30
This command sets the values for three fields: “id”, “name”, and “age”, with their respective values “123”, “john”, and “30”. The data is stored as a hash in Redis with the name “user”.
Note that if the hash does not exist, it will be created with the specified fields and values. If the hash already exists, the fields specified in the command will be updated with the new values.