Redis中的常用的链表数据结构Redis低版本(3.2之前)中list数据结构底层就是使用链表来进行串联数据的!
Redis中在操作List数据结构时的结构图!在redis中并不是仅仅使用这一种双向的链表结构.关于ziplist等其他结构我们这里暂时不讨论。
typedef struct listNode {
    struct listNode *prev;
    struct listNode *next;
    void *value;
} listNode;
typedef struct listIter {
    listNode *next;
    int direction;
} listIter;
typedef struct list {
    listNode *head;
    listNode *tail;
    void *(*dup)(void *ptr);
    void (*free)(void *ptr);
    int (*match)(void *ptr, void *key);
    unsigned long len;
} list;
| 函数 | 作用 | 
|---|---|
| dup | 复制链表节点值 | 
| free | 释放链表节点值 | 
| match | 比对链表节点值与指定值是否想的相等 | 


| 位置 | 作用 | 
|---|---|
| zlbytes | ziplist字节长度;长度最长为(2^32)-1 | 
| zltail | 整个ziplist偏移量;四个字节 | 
| zllen | ziplist中存储的元素个数;两个字节 | 
| entryX | ziplist中元素 | 
| zlend | 结束位 。固定值0xFF=255 | 
typedef struct zlentry {
    unsigned int prevrawlensize, prevrawlen;
    unsigned int lensize, len;
    unsigned int headersize;
    unsigned char encoding;
    unsigned char *p;
} zlentry;
阅读量:2042
点赞量:0
收藏量:0