Private archive copy · Unofficial site · Content copyright belongs to Runoob Tutorial and the original authors · View Original

Redis Hmset Command

Redis Hmset Command

Redis Hash

The Redis Hmset command is used to set multiple field-value pairs into the hash at once.

This command overwrites fields that already exist in the hash.

If the hash does not exist, an empty hash is created and the HMSET operation is performed.

Syntax

The basic syntax of the redis Hmset command is as follows:



redis 127.0.0.1:6379> HMSET KEY_NAME FIELD1 VALUE1 ...FIELDN VALUEN  

Available Version

= 2.0.0

Return Value

If the command is executed successfully, returns OK.

Example



redis 127.0.0.1:6379> HMSET myhash field1 "Hello" field2 "World"

OK

redis 127.0.0.1:6379> HGET myhash field1

"Hello"

redis 127.0.0.1:6379> HGET myhash field2

"World"

Redis Hash