Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

Hash-内部编码

  • 散列(哈希键值对)

  • 源代码文件:t_hash.c

  • 可选编码类型

    • ziplist —— OBJ_ENCODING_ZIPLIST
      • 压缩链表,少于512个元素、且元素均小于64字节时采用
        • 512 是 hash-max-ziplist-entries 的默认值
        • 64 是 hash-max-ziplist-value 的默认值
      • 更紧凑更节约内存,但在元素过多过大时读写效率会降低
    • hashtable —— OBJ_ENCODING_HT
      • 哈希表
      • 更快但也更耗内存
  • 对应底层实现文件:分别在ziplist.cdict.c