Learning redis source code [linked list]

Source: Internet
Author: User
Introduction

Redis implements a two-way linked list containing an iterator. The basic function is a universal two-way linked list. The source code implementation is worth reading the following.

Source File

Adlist. h adlist. c

Analysis

Here we will mainly introduce its main data structure and other linked list-related operations. If you are interested, you can view the source code by yourself. There are still a lot of tricky details.

/* Node, list, And iterator are the only data structures used currently. * // ** linked list node */typedef struct listnode {// struct listnode * Prev; // subsequent node struct listnode * Next; // value void * value ;} listnode;/** linked list iterator */typedef struct listiter {// next node listnode * Next; // iteration direction int ction;} listiter; /** linked list */typedef struct list {// header pointer listnode * head; // table tail pointer listnode * tail; // number of nodes unsigned long Len; // copy function void * (* DUP) (void * PTR); // release function void (* free) (void * PTR); // Compare function int (* match) (void * PTR, void * Key);} List;

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.