In my application im using redis database.I have gone through their documentation but i couldn't find the difference between HSET and HMSET.
相关问题
- NOT DISTINCT query in mySQL
- Flush single app django 1.9
- Getting Redis Master address from Sentinel C#
- keeping one connection to DB or opening closing pe
- Mysql-installer showing error : Memoy could not be
HSET key field value:
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.
HMSET is like HSET, but it allows multiple field/value pairs to be set at once.
Update
As of now, Oct 2017, HSET in the current redis version (4.0.2 on my machine) can also set multiple key-value pairs.
So these commands are now identical.
The only difference between the commands
HSET
andHMSET
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 )HMSET returns a simple string as a reply.