前几天读了redis双链表的实现,一个标准的双链表,但是也实现了存储任意类型,用void*,真的是奇淫技巧,可能是我见识少,感觉也能实现内核链表那种感觉,今天看来记录一下。
首先是结构定义
c/* Node, List, and Iterator are the only data structures used currently. */
typedef struct listNode { //指针和数据耦合在一起,非侵入式
struct listNode *prev;
struct listNode *next;
void *value;
} listNode;
What is Redis?
Redis is a fast in-memory NoSQL database and cache. Besides open-source, written in C, and designed for speed, Redis means “Remote Dictionary Server”.
Its fundamental data types are strings, lists, hashes, sets, and sorted sets; therefore Redis is often referred to as a data structure server. Many other data structures and capabilities for geolocation and stream processing are also available.
cubuntu@VM-8-16-ubuntu:~$ strace redis-server
// 切换到了执行文件
execve("/usr/local/bin/redis-server", ["redis-server"], 0x7fff26814f30 /* 27 vars */) = 0
brk(NULL) = 0x5575ff3bb000
arch_prctl(0x3001 /* ARCH_??? */, 0x7ffe24c54730) = -1 EINVAL (Invalid argument)
mmap(NULL, 8192, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7f1c37962000