您的当前位置:首页 >域名 >Redis热点之底层实现篇 正文

Redis热点之底层实现篇

时间:2025-11-04 08:06:03 来源:网络整理编辑:域名

核心提示

复制//哈希节点结构 typedefstructdictEntry{ void*key; union{ void

Redis热点之底层实现篇
复制//哈希节点结构  typedef struct dictEntry {   void *key;   union {   void *val;   uint64_t u64;   int64_t s64;   double d;   } v;   struct dictEntry *next;  } dictEntry;  //封装的点之底层是字典的免费信息发布网操作函数指针  typedef struct dictType {   uint64_t (*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. */  //哈希表结构 该部分是理解字典的b2b信息网关键  typedef struct dictht {   dictEntry **table;   unsigned long size;   unsigned long sizemask;   unsigned long used; } dictht;  //字典结构  typedef struct dict {   dictType *type;   void *privdata;   dictht ht[2];   long rehashidx; /* rehashing notin progress if rehashidx == -1 */   unsigned long iterators; /* number of iterators currently running */ } dict;  1.2.3.4.5.6.7.8.9.10.11.12.13.14.15.16.17.18.19.20.21.22.23.24.25.26.27.28.29.30.31.32.33.34.35.36.37.38.39.40.