日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程资源 > 编程问答 >内容正文

编程问答

redis代码 支持的数据结构

發布時間:2025/3/21 编程问答 21 豆豆
生活随笔 收集整理的這篇文章主要介紹了 redis代码 支持的数据结构 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
String.................................... typedef char *sds;struct sdshdr {int len;int free;char buf[]; };//buf[]不占結構體shshdr的空間。 都是通過buf獲取對應的sdshdr的指針,來獲取其他成員len/free; 內存的申請和釋放也是以sdshdr為申請單位。 Strings支持的操作類似char *; 有cat, cpy, dup, range(sub), cmp, trim等static inline size_t sdslen(const sds s) {struct sdshdr *sh = (void*)(s-(sizeof(struct sdshdr)));/s更前面是個頭部, 包含len與free信息。return sh->len; }static inline size_t sdsavail(const sds s) {struct sdshdr *sh = (void*)(s-(sizeof(struct sdshdr)));return sh->free; }hash table.......................................................................... typedef struct dictEntry {void *key;union {void *val;uint64_t u64;int64_t s64;} v;struct dictEntry *next; } dictEntry;typedef struct dictType {unsigned int (*hashFunction)(const void *key);void *(*keyDup)(void *privdata, const void *key);void *(*valDup)(void *privdata, const void *obj);int (*keyCompare)(void *privdata, const void *key1, const void *key2);void (*keyDestructor)(void *privdata, void *key);void (*valDestructor)(void *privdata, void *obj); } dictType;/* This is our hash table structure. Every dictionary has two of this as we* implement incremental rehashing, for the old to the new table. */ typedef struct dictht {dictEntry **table;//一維數組, 數組元素是dictEntry* 類型。unsigned long size;//table數組的長度、桶個數unsigned long sizemask;//size - 1用于 與hash(key) ^ sizemask, 得到的值將永遠<=sizeunsigned long used;//總元素個數 } dictht;typedef struct dict {dictType *type;//hash計算中的一組函數指針。void *privdata;dictht ht[2];//用于expand/rehash時的切換;int rehashidx; /* rehashing not in progress if rehashidx == -1 */int iterators; /* number of iterators currently running */ } dict;支持fetch/add/replace/find等操作adlist, linked list....................................... add/insert/del/search 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;




redisServer? 類似于數據庫

redisServer::db[] 類似于數據庫的db

redisServer::db->dict類似于table; dict中的<key, value>類似于表記錄。? db只有1個dict。


rdb。。。。

rdbSaveBackground?? fork子進程, 在子進程內調用rdbSave遍歷所有并 進行寫文件。


aof。。。。優先級比rdb高。

類似于mysql的binlog


總結

以上是生活随笔為你收集整理的redis代码 支持的数据结构的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。