REDIS data structure storage linked list design details (Redis design and implementation notes)

Source: Internet
Author: User

Redis has a flexible extension and gets a double-ended list with a table header complexity of O (1), which is divided into list and listNode2 components.

List

1typedefstructList {//Linked list2ListNode *head;//Linked list Header3ListNode *tail;//Chain Footer4     void* (*dup) (void*PTR);//copy function Pointers5     void(* Free)(void*PTR);//releasing the memory function pointer6     int(*match) (void*ptr,void*key);//Compare function Pointers7UnsignedLongLen//Linked list length8} list;

ListNode:

1 struct ListNode {  2     struct listnode *prev;   precursor pointer   3     struct listnode *next;   successor Pointer   4     void// node value   5 } ListNode;  

The following are the implementation principles of a doubly linked list:

The meaning of the list structure exists:
1. The time complexity for getting the first and the trailing elements is O (1), and you can choose to traverse the linked list elements backwards or forwards
2. Get the number of elements time complexity is 0 (1), the number of elements can be quickly removed without traversing

REDIS data structure storage linked list design details (Redis design and implementation notes)

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.