Home > Database > Redis > What are the related commands for redis ordered collections?

What are the related commands for redis ordered collections?

藏色散人
Release: 2020-07-01 09:57:33
Original
3866 people have browsed it

The related commands of redis ordered collection are: 1. "ZADD", call the ziplistInsert function, insert the members and scores into the compressed list as two nodes respectively; 2. "ZCARD", call the ziplistLen function, Get the number of nodes contained in the compressed list; 3. "ZCOUND" command, etc.

What are the related commands for redis ordered collections?

Implementation method of ordered set command

Command ziplist encoding implementation method zset encoding implementation method
ZADD Call ziplistInsert function , insert members and scores into the compressed list as two nodes respectively First call the zslInsert function to add the new element to the jump table, and then call the dictAdd function to associate the new element to the dictionary
ZCARD Call the ziplistLen function to get the number of nodes contained in the compressed list, divide this number by 2 to get the number of set elements Access the jump table data structure length attribute, directly accessing the number of collection elements
ZCOUND Traverse the compressed list and count the number of nodes with scores within a given range Traverse the jump table and count the number of nodes with scores within a given range
ZRANGE Traverse the compressed list from the head to the end of the table and return the given index range All elements in Traverse the jump table from the head to the end of the table, and return all elements within the given index range
ZREVRANGE Tail of the table Traverse the compressed list toward the head and return all elements in the given index range Traverse the jump table from the end of the table to the head and return all elements in the given index range
ZRANK Traverse the compressed list from the head to the end of the table, find the given member, and record the number of nodes passing through it along the way. When a given member is found, the number of nodes along the way is the number of elements corresponding to the member. Ranking Traverse the jump table from the head to the end of the table, find the given member, and record the number of nodes passing through it along the way. When a given member is found, the number of nodes along the way is the ranking of the element corresponding to the member
ZREVRANK Traverse the compressed list from the end of the table to the head, find the given member, and record the number of nodes passing through along the way. When the given member is found, the nodes along the way The number is the ranking of the element corresponding to the member. Traverse the jump table from the end of the table to the head, look for the given member, and record the number of nodes passing through along the way. When the given member is found, the number of nodes along the way It is the ranking of the element corresponding to the member
ZREM Traverse the compressed list, delete all nodes containing the given member, and the score nodes next to the deleted member node Traverse the jump table and delete all jump table nodes that contain the given member. And disassociate the member and score of the deleted element in the dictionary
ZSCORE Traverse the compressed list, find the node that contains the given member, and then take out the member node The element score saved by the score node next to it Get the score of the given member directly from the dictionary

Related learning recommendations:redis Tutorial

The above is the detailed content of What are the related commands for redis ordered collections?. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template