preface
< Redis design and Implementation >, as the saying goes, if you want to use something well, you must understand the content composition mechanism, so I took notes to understand the internal data structure.
Where Redis is used
- An ordered set
- Cluster nodes
Jump table
What is a skip list? A skip list is a data structure made up of
- List stores the entire contents of a skip list
- ListNode stores the contents of skip list nodes
The data structure
list
Skip list contains the following structures
- Header points to the skip table head node
- Tail Indicates the node at the end of the skip list
- Length indicates the number of nodes in the skip list, excluding the head node
- Level represents the maximum level value in a skip table node, excluding the head node
listNode
- The level [] array contains levels ranging from 1 to 32, and each level contains two attributes:
- Forward: indicates the position of a node
- Span Distance between the current node and a node
- Backward points to the previous node
- Score points
- Objects contained in obj (SSD string)
Figure said
conclusion
- Skip lists are one of the underlying implementations of ordered collections
- A Redis skip list is a list of two structures,listNode.
- The number of skip table node layers ranges from 1 to 32
- The scores in the skip list nodes can be the same but the object (obj) is unique
- Skip list nodes sort by the size of the score, and sort by the dictionary size of the object with the same score.
Take notes to reinforce your memory.