In my application im using redis database.I have gone through their documentation but i couldn't find the difference between HSET and HMSET.
3 Answers
HSET used to be able to set only one key-value pair. And if you needed to set several at once, you would have to use HMSET (M for multi). That was changed a few years ago, to allow both commands to accept multiple pairs. And now HMSET is redundant.
From official documentation:
As per Redis 4.0.0, HMSET is considered deprecated. Please use HSET in new code.

- 226,338
- 43
- 373
- 367
-
11According to official documentation: "As per Redis 4.0.0, HMSET is considered deprecated. Please use HSET in new code." – 18augst Oct 16 '19 at 07:46
-
@18augst: thanks for flagging this. Reworked my answer. – Sergio Tulentsev Oct 16 '19 at 08:06
-
Hi, in my redis-cli which of version 4.0.9, they both work – Anshuman Kumar Feb 01 '21 at 10:31
Sets field in the hash stored at key to value. If key does not exist, a new key holding a hash is created. If field already exists in the hash, it is overwritten.
HMSET key field value [field value ...]
Sets the specified fields to their respective values in the hash stored at key. This command overwrites any existing fields in the hash. If key does not exist, a new key holding a hash is created.
For more redis commands information, click here.

- 3,295
- 3
- 27
- 33
The only difference between the commands HSET
and HMSET
is the return value of the commands.
HSET return value (Integer reply):
#
if the field is a new field in the hash and value was set. (where#
is the number of new fields created )- 0 if the field already exists in the hash and the value was updated.
HMSET returns a simple string as a reply.

- 611
- 1
- 8
- 21