HMSET
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.
Return value
Section titled “Return value”| Case | RESP2 | RESP3 |
|---|---|---|
| Success | Simple string OK |
Simple string OK |
Errors:
WRONGTYPEifkeyholds a value that is not a hash.ERR wrong number of arguments for 'hmset' commandif no pair is given or a field has no value.
Examples
Section titled “Examples”127.0.0.1:6379> HMSET user:1 name "Ada" lang "en"OK127.0.0.1:6379> HGET user:1 lang"en"Compatibility
Section titled “Compatibility”Same as Redis 7.4 and Valkey 8, where it is also deprecated in favour of
HSET.
See also
Section titled “See also”Was this page helpful?
Thanks for the feedback.