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

How many field can there be in a hash within a redis

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

Share

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

How many field can there be in a hash within a redis? In view of this problem, this article introduces the corresponding analysis and answers in detail, hoping to help more partners who want to solve this problem to find a more simple and feasible way.

Hash is a mapping table for field and value of type string. Both add and delete operations are O (1) (average) complexity. The hash type is particularly suitable for storing objects. When the number of field is within the limit and the length of value is less than the specified number of bytes, then the hash type is stored in zipmap, so it will save memory. You can modify the configuration items in the configuration file to control the number of field and the number of bytes of value.

Hash-max-zipmap-entries 512 # configuration fields up to 512

Hash-max-zipmap-value 64 # configures value with a maximum of 64 bytes.

If the above two conditions must be met, the key will be compressed. Otherwise, the hash type key is stored according to the normal hash structure.

[note] these two configurations do not limit the maximum number of field and the maximum number of bytes of value that can be stored in the hash structure, but that when the number of field does not exceed the configured number, and the length of the value corresponding to each filed is less than the specified number of bytes, note that when both conditions are met, the storage of the key is the zipmap, that is, compressed data, saving space. When the number of field exceeds, or there is a value length greater than the specified length, then the entire key will be stored in memory using the normal hash structure.

Redis hash is a mapping table for field and value of type string, and hash is particularly suitable for storing objects.

Each hash in Redis can store 232-1 key-value pairs (more than 4 billion).

Example

127.0.1 HMSET Rediskey name "redis tutorial" description "redis basic commands for caching" likes 20 visitors 23000OK127.0.0.1:6379 > HGETALL Rediskey 1) "name" 2) "redis tutorial" 3) "description" 4) "redis basic commands for caching" 5) "likes" 6) "20" 7) "visitors" 8) "23000" this is the answer to the question about how many field can be in a hash in redis. I hope the above content can help you to a certain extent, if you still have a lot of doubts to be solved, you can follow the industry information channel to learn more related knowledge.

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