Notes of Redis Design

Simple Dynamic String (SDS)

struct sdshdr {
    int len;
    int free;
    char buf[];
}

Binary safe

Uses len instead of \0 to judge the endig of a string.

Linked List

typedef struct listNode {
    struct listNode* prev;
    struct listNode* next;
    void* value;
}listNode;
typedef struct list{
    listNode* head;
    listNode* tail;
    unsigned long len;
    void *(*dup) (void* ptr);
    void *(*free) (void* ptr);
    int *(*match) (void* ptr);
}list;
Share: X (Twitter) Facebook LinkedIn