The linked list is a widely used data structure in redis. In many cases, the underlying structure of the list structure is implemented using the linked list.
The linked list is defined in the header file adlist. H. It is a common two-way linked list with the following structure:
1 // linked list Node 2 typedef struct listnode {3 struct listnode * Prev; // refers to the previous node 4 struct listnode * Next; // points to the next node 5 void * value; // value range 6} listnode; 7 // iteration pointer of linked list traversal 8 typedef struct listiter {9 listnode * Next; // next node pointer 10 int direction; // direction 11} listiter; 12 13 // chain table structure 14 typedef struct list {15 listnode * head; // head pointer of the chain table 16 listnode * tail; // The end pointer of the linked list 17 void * (* DUP) (void * PTR); // The Node value copying function pointer 18 void (* free) (void * PTR ); // node value range release function pointer 19 int (* match) (void * PTR, void * Key); // node value range comparison function pointer 20 unsigned long Len; // chain table length 21} List;