Create an account

Very important

  • To access the important data of the forums, you must be active in each forum and especially in the leaks and database leaks section, send data and after sending the data and activity, data and important content will be opened and visible for you.
  • You will only see chat messages from people who are at or below your level.
  • More than 500,000 database leaks and millions of account leaks are waiting for you, so access and view with more activity.
  • Many important data are inactive and inaccessible for you, so open them with activity. (This will be done automatically)


Thread Rating:
  • 516 Vote(s) - 3.55 Average
  • 1
  • 2
  • 3
  • 4
  • 5
What is the difference between HSET and HMSET method in redis database

#1
In my application im using redis database.I have gone through their documentation but i couldn't find the difference between HSET and HMSET.
Reply

#2
**[HSET key field value][1]:**

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 ...\]][2]**

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].


[1]:

[To see links please register here]

[2]:

[To see links please register here]

[3]:

[To see links please register here]

Reply

#3
The only difference between the commands [`HSET`](

[To see links please register here]

) and [`HMSET`](

[To see links please register here]

) 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.

Reply

#4
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](

[To see links please register here]

):

> As per Redis 4.0.0, HMSET is considered deprecated. Please use HSET in new code.

Reply



Forum Jump:


Users browsing this thread:
1 Guest(s)

©0Day  2016 - 2023 | All Rights Reserved.  Made with    for the community. Connected through