Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

Commands related to Hash hash data type

2025-01-16 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >

Share

Shulou(Shulou.com)06/01 Report--

Hash php-like array

Hset key field value

Function: set the value of the filed field in key to value

Note: if there is no field field, add it directly, and if so, overwrite the value of the original field field

Hmset key field1 value1 [field2 value2 field3 value3 .fieldn valuen]

Function: set field1- > N fields, and the corresponding value is value1- > N

(the corresponding PHP is understood as $key = array (file1= > value1, field2= > value2. FieldN = > valueN))

Hget key field

Function: returns the value of the field field in key

Hmget key field1 field2 fieldN

Purpose: returns the value of the field1 field2 fieldN field in key

Hgetall key

Function: returns all fields and their values in key

Hdel key field

Purpose: delete the field domain in key

Hlen key

Function: returns the number of elements in key

Hexists key field

Function: to determine whether there is a field domain in key

Hinrby key field value

Function: to increase the value of the field field in key to the integer value value

Hinrby float key field value

Function: to increase the value of the field field in key to a floating point value value

Hkeys key

Function: returns all field in key

Kvals key

Function: returns all value in key

Note:

When saving session, it should be in hash!

(1) Strings are only used in small-scale data records. If the amount of data exceeds the million level, using strings to save simple mapping relationships will waste a lot of memory. At this point, you need to use another data structure of Redis-Hash. To store data of the same order of magnitude, the memory consumed by the Hash structure is only 1x4 of the string structure, but the query speed is no worse than the string. The structure of Hash will be explained in Chapter 9.

(2) if there is a large amount of Key in the Redis, the execution of the "keys *" command will have a temporary impact on the performance of the Redis, and even cause the Redis to lose its response. Therefore, you should never rashly list all the current Key without knowing how many Key there are.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Database

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report