Skip to content

Ask the HotKV docs

Answers come only from these docs and can be wrong; check the linked pages before you rely on them.

HMSET

Last updated

Deprecated: use HSET instead.

HMSET key field value [field value ...]
Group
Hash
Complexity
O(N) where N is the number of fields being set
Arity
-4 (at least 4 words, counting the command name)
Flags
write, fast
Keys
first 1, last 1, step 1
HotKV Cloud
All plans
On-Premise
no license needed

HMSET writes each field and value pair into the hash at key, creating the hash if needed. It behaves exactly like HSET (including removing the time to live of each field it overwrites), except that it replies OK instead of the number of new fields. New code should use HSET, which accepts several pairs too.

Case RESP2 RESP3
Success Simple string OK Simple string OK

Errors:

  • WRONGTYPE if key holds a value that is not a hash.
  • ERR wrong number of arguments for 'hmset' command if no pair is given or a field has no value.
127.0.0.1:6379> HMSET user:1 name "Ada" lang "en"
OK
127.0.0.1:6379> HGET user:1 lang
"en"

Same as Redis 7.4 and Valkey 8, where it is also deprecated in favour of HSET.

HSET, HMGET, HSETEX