当前位置:网站首页>Hash of redis command

Hash of redis command

2022-06-25 18:14:00 [email protected]

1. hset

hset hash field value: Sets the value for the specified field in the hash

  1. If the given field does not exist in the hash , Then this setting is a creation operation , The command will associate the given field and value in the hash , Then return
  2. If the given field already exists in the hash , This setting is an update operation , The command will overwrite the old value of the field with the new value given by the user , Then return 0
     Insert picture description here
    Storage in the database :
     Insert picture description here

Add NX Options : You can set only when the field does not exist
 Insert picture description here


2. hget

hget hash field: Get the value of the specified field in the hash
 Insert picture description here
 Insert picture description here


3. hincrby

hincrby hash field increment: If the hash field stores information that can be used by Redis Numbers interpreted as integers , Then users can use HINCRBY The command adds the specified integer increment to the value of the field
 Insert picture description here If you want to subtract , Only need to increment Set to a negative number

  1. Field must be an integer
  2. The increment must also be an integer
     Insert picture description here

4. hincrbyfloat

hincrbyfloat hash field increment Fields can be integers or floating point numbers , The increment can also be an integer or a floating point number
 Insert picture description here
If you want to subtract , Only need to increment Set to a negative number


5. hstrlen

hstrlen hash filed: Gets the byte length of the given field value

 Insert picture description here
 Insert picture description here


6. hexists

hexists hash field: Check whether the field given by the user exists in the hash , There is returned 1, Otherwise return to 0
 Insert picture description here


7. hdel

hdel hash field: Deletes the specified field and its associated value in the hash
 Insert picture description here
Delete successful return 1;
Delete failed return 0( Hash does not exist or filed non-existent )


8. hlen

hlen hash: Gets the number of fields contained in a given hash
 Insert picture description here
Hash if not present , that HLEN The command will return 0 As a result


9. hmset

hmset hash field1 value1 field value2...: Set values for multiple fields in the hash at once
 Insert picture description here
If the field given by the user already exists in the hash , that HMSET The command will overwrite the existing old value of the field with the new value given by the user


10. hmget

hmget hash field1 field2...: Get the values of multiple fields from the hash at once
 Insert picture description here
Returns when the field does not exist or the hash does not exist nil


11. hkeys

hkeys hash: Get all the fields in the hash
 Insert picture description here


12. hvals

hvals hash: Get the values of all fields in the hash
 Insert picture description here


13. hgetall

hgetall hash: Get all fields and values
 Insert picture description here

原网站

版权声明
本文为[[email protected]]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/02/202202190532337449.html