HMSET
Since 1.1.0Hashes
Syntax
HMSET key field value [field value ...]Sets fields of the hash at key, each to its value, as HSET does, and replies OK instead of a count. HSET has taken several field-value pairs since Redis 4.0; HMSET remains for clients written before that. In new code use HSET, which also tells you how many fields were added.
The behaviour is otherwise that of HSET:
- a missing key is created as a hash;
- existing fields are overwritten, and keep their place in the hash's field order;
- setting a field that has an expiry removes the expiry;
- a field given twice takes the last value.
Reply
OK.
Errors
ERR wrong number of arguments for 'hmset' commandif a field has no value.WRONGTYPE Operation against a key holding the wrong kind of valueif the key holds something other than a hash.
Examples
> HMSET u name Ada lang Rust
OK
> HMSET u name Grace lang COBOL
OK
> HGETALL u
1) "name"
2) "Grace"
3) "lang"
4) "COBOL"
> HMSET u name
(error) ERR wrong number of arguments for 'hmset' command