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

What are the data types in Redis

2025-04-06 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >

Share

Shulou(Shulou.com)05/31 Report--

What are the data types in Redis, many novices are not very clear about this, in order to help you solve this problem, the following editor will explain for you in detail, people with this need can come to learn, I hope you can gain something.

Redis is not a simple key-value pair storage, it is actually a storage that supports various types of data structures. In traditional key value storage, string keys are associated with string values, but in Redis, these values are not limited to simple strings, but can also support more complex data structures.

Here are the data structures supported by Redis:

Ordered sets (SortedSet): similar to collections, but each string element is associated with a number called score. Elements are always sorted by their score, and elements with a certain range of score can be retrieved.

Hash: a mapping consisting of a field associated with a value, both of which are strings.

Bitmap (Bitmap): manipulate string values like an array of bits, set and clear a bit, count all bits that are 1, find the first bit that sets 1, find the first bit that sets 0, and so on.

HyperLogLogs: a probabilistic data structure that uses small memory space to count the number of unique elements with an error of less than 1%.

String (String): binary secure string.

List: a list of string elements sorted by insertion order, based on a linked list.

Set: a unique collection of disordered string elements.

Key (Key)

Keys are binary safe, which means you can use any binary sequence as a key, either as a string such as OneMoreStudy, or to make the contents of an image file, an empty string, a valid key. However, there are other rules:

Other rules for keys

Do not use overly long keys, such as a 1KB key. Not only does it take up more memory, but finding keys in a dataset may require some time-consuming key comparisons. If you do have a larger key, it's a good idea to hash it first (for example, MD5, SHA1).

Do not use keys that are too short, such as OMS100f, which is more readable than one-more-study:100:fans. It may take up more memory, but the amount of memory added by keys is much smaller than the memory occupied by values. We need to find a balance, neither long nor short.

Multiple fields are separated by colons, and multiple words in a field are separated by hyphens or dots, such as: one-more-study:100:fans, or one.more.study:100:fans.

The maximum value allowed for the key is 512MB.

Is it helpful for you to read the above content? If you want to know more about the relevant knowledge or read more related articles, please follow the industry information channel, thank you for your support.

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