Redis - Hash Hmset Command


Advertisements

Redis HMSET command is used to set the specified fields to their respective values in the hash stored at the key. This command overwrites any existing fields in the hash. If the key does not exist, a new key holding a hash is created.

Return Value

Simple string reply.

Syntax

Following is the basic syntax of Redis HMSET command.

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

Example

redis 127.0.0.1:6379> HMSET myhash field1 "foo" field2 "bar" 
OK 
redis 127.0.0.1:6379> HGET myhash field1 
"foo" 
redis 127.0.0.1:6379> HGET myhash field2 
"bar"
redis_hashes.htm
Advertisements