Home >Database >Redis >What data structures does Redis support?

What data structures does Redis support?

王林
王林Original
2020-06-29 15:03:384484browse

The data structures supported by Redis are: 1. string; 2. Doubly linked list; 3. dict; 4. Sorting set; 5. Hash type. Redis provides persistence mechanism and data synchronization to avoid the loss of all original data retained in the memory after a server problem occurs.

What data structures does Redis support?

Redis provides persistence mechanism and data synchronization, avoiding the problem of avalanche after downtime, that is, after the server has problems, the original data retained in the memory All is lost and the data needs to be reorganized into memory. At this time, Memcached will go through a very slow process.

(Recommended learning: redis tutorial)

Redis’ support for persistence is only one of its weapons. In addition, it also provides many functions for different needs. There are up to 5 data storage methods to achieve your needs with maximum efficiency. Let’s talk about them separately below:

1. String (string)

string is the most A simple type can be understood as the same type as Memcached. One key corresponds to one value, and the operations supported are similar to those of Memcached. But it's much more feature-rich.

2. List (double linked list)

list is a linked list structure, its main functions are push, pop, getting all values ​​in a range, etc. The reason why it is bidirectional is that it can operate on the left and right sides of the linked list respectively

3. dict (hash table)

set is a set , similar to the concept of sets in our mathematics, operations on sets include adding and deleting elements, and performing intersection and difference operations on multiple sets. In the operation, the key is understood as the name of the set

4. zset (sorting set)

zset is an upgraded version of set. It is based on set An order attribute has been added. This attribute can be specified when adding and modifying elements. Each time it is specified, zset will automatically re-adjust the order according to the new value. You can set the sorting weight for the value of the specified key. It uses the ranking module more

5. Hash type

Redis can store key pairs data of an attribute (such as user1.uname user1.passwd). Of course, you can store these attributes in json format and operate it directly as a string type, but this will have an impact on performance, so redis proposed Hash type.

The above is the detailed content of What data structures does Redis support?. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn