Current location - Plastic Surgery and Aesthetics Network - Plastic surgery and medical aesthetics - What are the data types of Redis?
What are the data types of Redis?
I. String | String Type

Redis is a string type and can store strings, integers or floating-point numbers. If an integer or floating-point number is stored, it can also perform self-increment or self-decrement operations. Reids's string type is binary and can contain any data, such as serialized objects, pictures, byte streams and so on. , but the upper limit of storage size is 5 12M.

Redis defines its own data structure at the bottom.

II. List | List Type

The list type of Redis is similar to that in many programming languages, which can store multiple strings in order and support pushing or popping elements from the left and right ends of the list. The underlying implementation of Redis list is compressed list, data structure and double-headed linked list realized by Redis content itself.

Insert one or more values in the list header. If the key does not exist, an empty list will be created and the LPUSH operation will be performed. Dang key

When it exists but is not a list type, an error will be returned.

Three. Collection | collection type

Redis's collection stores many different elements in an unordered way, and attention should be paid to disorder and difference here. In addition to adding, deleting and checking whether elements are in a set, you can also perform intersection, union and difference operations on multiple sets.

The underlying implementation of Redis collection type is mainly through a data structure called dictionary. However, in order to pursue the ultimate performance, Redis will choose the intset data structure according to whether the stored value is an integer. When certain conditions are met, it will switch to the implementation of the dictionary.

Four, hash hash table (hash table)

The hash type of redis is actually a smaller version of Redis. It stores key-value pairs and stores multiple key-value pairs in a redis key.

The bottom layer of hash type is mainly dictionary-based data structure.

Five, zset | ordered set

Compared with set, ordered set has many ordered words. We know that the elements stored in set set type are out of order, so how can the ordered set of Redis ensure order? Using scores, the ordered set stores the mapping between the members and scores, and provides a score processing command and a command to obtain members or scores in order according to the size of the scores.

The realization of Redis ordered set uses a data structure called jump table (referred to as jump table, which can be consulted by itself), and also uses the compressed list mentioned above. If certain conditions are met, it will be converted by itself.