| @ -0,0 +1,685 @@ | |||
| <!DOCTYPE html> | |||
| <html lang="zh-Hans"> | |||
| <head> | |||
| <meta charset="UTF-8"> | |||
| <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=2"> | |||
| <meta name="theme-color" content="#222"> | |||
| <meta name="generator" content="Hexo 4.2.0"> | |||
| <link rel="apple-touch-icon" sizes="180x180" href="/images/apple-touch-icon-next.png"> | |||
| <link rel="icon" type="image/png" sizes="32x32" href="/images/favicon-32x32-next.png"> | |||
| <link rel="icon" type="image/png" sizes="16x16" href="/images/favicon-16x16-next.png"> | |||
| <link rel="mask-icon" href="/images/logo.svg" color="#222"> | |||
| <meta name="google-site-verification" content="2X6S9P7CAjXjVvw8YyQR8pCu-B0oEu7O9quLgxXuWyA"> | |||
| <meta name="baidu-site-verification" content="dV8JGNzi0c"> | |||
| <link rel="stylesheet" href="/css/main.css"> | |||
| <link rel="stylesheet" href="//fonts.loli.net/css?family=Lato:300,300italic,400,400italic,700,700italic|M+ 2p:300,300italic,400,400italic,700,700italic&display=swap&subset=latin,latin-ext"> | |||
| <link rel="stylesheet" href="/lib/font-awesome/css/font-awesome.min.css"> | |||
| <link rel="stylesheet" href="//cdn.jsdelivr.net/gh/fancyapps/fancybox@3/dist/jquery.fancybox.min.css"> | |||
| <link rel="stylesheet" href="/lib/pace/pace-theme-minimal.min.css"> | |||
| <script src="/lib/pace/pace.min.js"></script> | |||
| <script id="hexo-configurations"> | |||
| var NexT = window.NexT || {}; | |||
| var CONFIG = { | |||
| hostname: new URL('https://nicksxs.me').hostname, | |||
| root: '/', | |||
| scheme: 'Pisces', | |||
| version: '7.7.0', | |||
| exturl: false, | |||
| sidebar: {"position":"left","display":"post","padding":18,"offset":12,"onmobile":false}, | |||
| copycode: {"enable":true,"show_result":false,"style":null}, | |||
| back2top: {"enable":true,"sidebar":false,"scrollpercent":false}, | |||
| bookmark: {"enable":false,"color":"#222","save":"auto"}, | |||
| fancybox: true, | |||
| mediumzoom: false, | |||
| lazyload: true, | |||
| pangu: false, | |||
| comments: {"style":"tabs","active":null,"storage":true,"lazyload":false,"nav":null}, | |||
| algolia: { | |||
| appID: '', | |||
| apiKey: '', | |||
| indexName: '', | |||
| hits: {"per_page":10}, | |||
| labels: {"input_placeholder":"Search for Posts","hits_empty":"We didn't find any results for the search: ${query}","hits_stats":"${hits} results found in ${time} ms"} | |||
| }, | |||
| localsearch: {"enable":false,"trigger":"auto","top_n_per_article":1,"unescape":false,"preload":false}, | |||
| path: '', | |||
| motion: {"enable":true,"async":false,"transition":{"post_block":"fadeIn","post_header":"slideDownIn","post_body":"slideDownIn","coll_header":"slideLeftIn","sidebar":"slideUpIn"}} | |||
| }; | |||
| </script> | |||
| <meta name="description" content="在 redis 中还有一类表型数据结构叫压缩表,ziplist,它的目的是替代链表,链表是个很容易理解的数据结构,双向链表有前后指针,有带头结点的有的不带,但是链表有个比较大的问题是相对于普通的数组,它的内存不连续,碎片化的存储,内存利用效率不高,而且指针寻址相对于直接使用偏移量的话,也有一定的效率劣势,当然这不是主要的原因,ziplist 设计的主要目的是让链表的内存使用更高效 The zip"> | |||
| <meta property="og:type" content="article"> | |||
| <meta property="og:title" content="redis数据结构介绍四-第四部分 压缩表"> | |||
| <meta property="og:url" content="https://nicksxs.me/2020/01/19/redis%E6%95%B0%E6%8D%AE%E7%BB%93%E6%9E%84%E4%BB%8B%E7%BB%8D%E5%9B%9B/index.html"> | |||
| <meta property="og:site_name" content="Nicksxs's Blog"> | |||
| <meta property="og:description" content="在 redis 中还有一类表型数据结构叫压缩表,ziplist,它的目的是替代链表,链表是个很容易理解的数据结构,双向链表有前后指针,有带头结点的有的不带,但是链表有个比较大的问题是相对于普通的数组,它的内存不连续,碎片化的存储,内存利用效率不高,而且指针寻址相对于直接使用偏移量的话,也有一定的效率劣势,当然这不是主要的原因,ziplist 设计的主要目的是让链表的内存使用更高效 The zip"> | |||
| <meta property="article:published_time" content="2020-01-18T16:00:22.000Z"> | |||
| <meta property="article:modified_time" content="2020-01-18T16:00:22.612Z"> | |||
| <meta property="article:author" content="Nicksxs"> | |||
| <meta property="article:tag" content="Redis"> | |||
| <meta property="article:tag" content="C语言"> | |||
| <meta property="article:tag" content="数据结构"> | |||
| <meta property="article:tag" content="源码"> | |||
| <meta property="article:tag" content="源码分析"> | |||
| <meta property="article:tag" content="压缩表"> | |||
| <meta property="article:tag" content="ziplist"> | |||
| <meta name="twitter:card" content="summary"> | |||
| <link rel="canonical" href="https://nicksxs.me/2020/01/19/redis%E6%95%B0%E6%8D%AE%E7%BB%93%E6%9E%84%E4%BB%8B%E7%BB%8D%E5%9B%9B/"> | |||
| <script id="page-configurations"> | |||
| // https://hexo.io/docs/variables.html | |||
| CONFIG.page = { | |||
| sidebar: "", | |||
| isHome: false, | |||
| isPost: true | |||
| }; | |||
| </script> | |||
| <title>redis数据结构介绍四-第四部分 压缩表 | Nicksxs's Blog</title> | |||
| <script async src="https://www.googletagmanager.com/gtag/js?id=UA-61358619-1"></script> | |||
| <script> | |||
| if (CONFIG.hostname === location.hostname) { | |||
| window.dataLayer = window.dataLayer || []; | |||
| function gtag(){dataLayer.push(arguments);} | |||
| gtag('js', new Date()); | |||
| gtag('config', 'UA-61358619-1'); | |||
| } | |||
| </script> | |||
| <script> | |||
| var _hmt = _hmt || []; | |||
| (function() { | |||
| var hm = document.createElement("script"); | |||
| hm.src = "https://hm.baidu.com/hm.js?20f33b3c0c0eff9b1522999c0015646d"; | |||
| var s = document.getElementsByTagName("script")[0]; | |||
| s.parentNode.insertBefore(hm, s); | |||
| })(); | |||
| </script> | |||
| <noscript> | |||
| <style> | |||
| .use-motion .brand, | |||
| .use-motion .menu-item, | |||
| .sidebar-inner, | |||
| .use-motion .post-block, | |||
| .use-motion .pagination, | |||
| .use-motion .comments, | |||
| .use-motion .post-header, | |||
| .use-motion .post-body, | |||
| .use-motion .collection-header { opacity: initial; } | |||
| .use-motion .site-title, | |||
| .use-motion .site-subtitle { | |||
| opacity: initial; | |||
| top: initial; | |||
| } | |||
| .use-motion .logo-line-before i { left: initial; } | |||
| .use-motion .logo-line-after i { right: initial; } | |||
| </style> | |||
| </noscript> | |||
| <link rel="alternate" href="/atom.xml" title="Nicksxs's Blog" type="application/atom+xml"> | |||
| </head> | |||
| <body itemscope itemtype="http://schema.org/WebPage"> | |||
| <div class="container use-motion"> | |||
| <div class="headband"></div> | |||
| <header class="header" itemscope itemtype="http://schema.org/WPHeader"> | |||
| <div class="header-inner"><div class="site-brand-container"> | |||
| <div class="site-meta"> | |||
| <div> | |||
| <a href="/" class="brand" rel="start"> | |||
| <span class="logo-line-before"><i></i></span> | |||
| <span class="site-title">Nicksxs's Blog</span> | |||
| <span class="logo-line-after"><i></i></span> | |||
| </a> | |||
| </div> | |||
| <p class="site-subtitle">What hurts more, the pain of hard work or the pain of regret?</p> | |||
| </div> | |||
| <div class="site-nav-toggle"> | |||
| <div class="toggle" aria-label="Toggle navigation bar"> | |||
| <span class="toggle-line toggle-line-first"></span> | |||
| <span class="toggle-line toggle-line-middle"></span> | |||
| <span class="toggle-line toggle-line-last"></span> | |||
| </div> | |||
| </div> | |||
| </div> | |||
| <nav class="site-nav"> | |||
| <ul id="menu" class="menu"> | |||
| <li class="menu-item menu-item-home"> | |||
| <a href="/" rel="section"><i class="fa fa-fw fa-home"></i>Home</a> | |||
| </li> | |||
| <li class="menu-item menu-item-about"> | |||
| <a href="/about/" rel="section"><i class="fa fa-fw fa-about"></i>About</a> | |||
| </li> | |||
| <li class="menu-item menu-item-tags"> | |||
| <a href="/tags/" rel="section"><i class="fa fa-fw fa-tags"></i>Tags</a> | |||
| </li> | |||
| <li class="menu-item menu-item-categories"> | |||
| <a href="/categories/" rel="section"><i class="fa fa-fw fa-categories"></i>Categories</a> | |||
| </li> | |||
| <li class="menu-item menu-item-archives"> | |||
| <a href="/archives/" rel="section"><i class="fa fa-fw fa-archives"></i>Archives</a> | |||
| </li> | |||
| <li class="menu-item menu-item-sitemap"> | |||
| <a href="/sitemap.xml" rel="section"><i class="fa fa-fw fa-sitemap"></i>Sitemap</a> | |||
| </li> | |||
| <li class="menu-item menu-item-commonweal"> | |||
| <a href="/404/" rel="section"><i class="fa fa-fw fa-heartbeat"></i>Commonweal 404</a> | |||
| </li> | |||
| </ul> | |||
| </nav> | |||
| </div> | |||
| </header> | |||
| <div class="back-to-top"> | |||
| <i class="fa fa-arrow-up"></i> | |||
| <span>0%</span> | |||
| </div> | |||
| <a href="https://github.com/nicksxs" class="github-corner" title="Follow me on GitHub" aria-label="Follow me on GitHub" rel="noopener" target="_blank"><svg width="80" height="80" viewBox="0 0 250 250" aria-hidden="true"><path d="M0,0 L115,115 L130,115 L142,142 L250,250 L250,0 Z"></path><path d="M128.3,109.0 C113.8,99.7 119.0,89.6 119.0,89.6 C122.0,82.7 120.5,78.6 120.5,78.6 C119.2,72.0 123.4,76.3 123.4,76.3 C127.3,80.9 125.5,87.3 125.5,87.3 C122.9,97.6 130.6,101.9 134.4,103.2" fill="currentColor" style="transform-origin: 130px 106px;" class="octo-arm"></path><path d="M115.0,115.0 C114.9,115.1 118.7,116.5 119.8,115.4 L133.7,101.6 C136.9,99.2 139.9,98.4 142.2,98.6 C133.8,88.0 127.5,74.4 143.8,58.0 C148.5,53.4 154.0,51.2 159.7,51.0 C160.3,49.4 163.2,43.6 171.4,40.1 C171.4,40.1 176.1,42.5 178.8,56.2 C183.1,58.6 187.2,61.8 190.9,65.4 C194.5,69.0 197.7,73.2 200.1,77.6 C213.8,80.2 216.3,84.9 216.3,84.9 C212.7,93.1 206.9,96.0 205.4,96.6 C205.1,102.4 203.0,107.8 198.3,112.5 C181.9,128.9 168.3,122.5 157.7,114.1 C157.9,116.9 156.7,120.9 152.7,124.9 L141.0,136.5 C139.8,137.7 141.6,141.9 141.8,141.8 Z" fill="currentColor" class="octo-body"></path></svg></a> | |||
| <main class="main"> | |||
| <div class="main-inner"> | |||
| <div class="content-wrap"> | |||
| <div class="content"> | |||
| <div class="posts-expand"> | |||
| <article itemscope itemtype="http://schema.org/Article" class="post-block " lang="zh-Hans"> | |||
| <link itemprop="mainEntityOfPage" href="https://nicksxs.me/2020/01/19/redis%E6%95%B0%E6%8D%AE%E7%BB%93%E6%9E%84%E4%BB%8B%E7%BB%8D%E5%9B%9B/"> | |||
| <span hidden itemprop="author" itemscope itemtype="http://schema.org/Person"> | |||
| <meta itemprop="image" content="/uploads/avatar.jpg"> | |||
| <meta itemprop="name" content="Nicksxs"> | |||
| <meta itemprop="description" content="learn from zero,技术博客,Nicksxs,史学森"> | |||
| </span> | |||
| <span hidden itemprop="publisher" itemscope itemtype="http://schema.org/Organization"> | |||
| <meta itemprop="name" content="Nicksxs's Blog"> | |||
| </span> | |||
| <header class="post-header"> | |||
| <h1 class="post-title" itemprop="name headline"> | |||
| redis数据结构介绍四-第四部分 压缩表 | |||
| </h1> | |||
| <div class="post-meta"> | |||
| <span class="post-meta-item"> | |||
| <span class="post-meta-item-icon"> | |||
| <i class="fa fa-calendar-o"></i> | |||
| </span> | |||
| <span class="post-meta-item-text">Posted on</span> | |||
| <time title="Created: 2020-01-19 00:00:22" itemprop="dateCreated datePublished" datetime="2020-01-19T00:00:22+08:00">2020-01-19</time> | |||
| </span> | |||
| <span class="post-meta-item"> | |||
| <span class="post-meta-item-icon"> | |||
| <i class="fa fa-folder-o"></i> | |||
| </span> | |||
| <span class="post-meta-item-text">In</span> | |||
| <span itemprop="about" itemscope itemtype="http://schema.org/Thing"> | |||
| <a href="/categories/Redis/" itemprop="url" rel="index"> | |||
| <span itemprop="name">Redis</span> | |||
| </a> | |||
| </span> | |||
| , | |||
| <span itemprop="about" itemscope itemtype="http://schema.org/Thing"> | |||
| <a href="/categories/Redis/%E6%95%B0%E6%8D%AE%E7%BB%93%E6%9E%84/" itemprop="url" rel="index"> | |||
| <span itemprop="name">数据结构</span> | |||
| </a> | |||
| </span> | |||
| , | |||
| <span itemprop="about" itemscope itemtype="http://schema.org/Thing"> | |||
| <a href="/categories/C/" itemprop="url" rel="index"> | |||
| <span itemprop="name">C</span> | |||
| </a> | |||
| </span> | |||
| , | |||
| <span itemprop="about" itemscope itemtype="http://schema.org/Thing"> | |||
| <a href="/categories/Redis/%E6%BA%90%E7%A0%81/" itemprop="url" rel="index"> | |||
| <span itemprop="name">源码</span> | |||
| </a> | |||
| </span> | |||
| , | |||
| <span itemprop="about" itemscope itemtype="http://schema.org/Thing"> | |||
| <a href="/categories/C/Redis/" itemprop="url" rel="index"> | |||
| <span itemprop="name">Redis</span> | |||
| </a> | |||
| </span> | |||
| </span> | |||
| <span class="post-meta-item"> | |||
| <span class="post-meta-item-icon"> | |||
| <i class="fa fa-comment-o"></i> | |||
| </span> | |||
| <span class="post-meta-item-text">Disqus: </span> | |||
| <a title="disqus" href="/2020/01/19/redis%E6%95%B0%E6%8D%AE%E7%BB%93%E6%9E%84%E4%BB%8B%E7%BB%8D%E5%9B%9B/#comments" itemprop="discussionUrl"> | |||
| <span class="post-comments-count disqus-comment-count" data-disqus-identifier="2020/01/19/redis数据结构介绍四/" itemprop="commentCount"></span> | |||
| </a> | |||
| </span> | |||
| </div> | |||
| </header> | |||
| <div class="post-body" itemprop="articleBody"> | |||
| <p>在 redis 中还有一类表型数据结构叫压缩表,ziplist,它的目的是替代链表,链表是个很容易理解的数据结构,双向链表有前后指针,有带头结点的有的不带,但是链表有个比较大的问题是相对于普通的数组,它的内存不连续,碎片化的存储,内存利用效率不高,而且指针寻址相对于直接使用偏移量的话,也有一定的效率劣势,当然这不是主要的原因,ziplist 设计的主要目的是让链表的内存使用更高效</p> | |||
| <blockquote> | |||
| <p>The ziplist is a specially encoded dually linked list that is designed to be very memory efficient.<br>这是摘自 redis 源码中ziplist.c 文件的注释,也说明了原因,它的大概结构是这样子</p> | |||
| </blockquote> | |||
| <figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line"><zlbytes> <zltail> <zllen> <entry> <entry> ... <entry> <zlend></span><br></pre></td></tr></table></figure> | |||
| <p>其中<br><code><zlbytes></code>表示 ziplist 占用的字节总数,类型是uint32_t,32 位的无符号整型,当然表示的字节数也包含自己本身占用的 4 个<br><code><zltail></code> 类型也是是uint32_t,表示ziplist表中最后一项(entry)在ziplist中的偏移字节数。<code><zltail></code>的存在,使得我们可以很方便地找到最后一项(不用遍历整个ziplist),从而可以在ziplist尾端快速地执行push或pop操作。<br><code><uint16_t zllen></code> 表示ziplist 中的数据项个数,因为是 16 位,所以当数量超过所能表示的最大的数量,它的 16 位全会置为 1,但是真实的数量需要遍历整个 ziplist 才能知道<br><code><entry></code>是具体的数据项,后面解释<br><code><zlend></code> ziplist 的最后一个字节,固定是255。<br>再看一下<code><entry></code>中的具体结构,</p> | |||
| <figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line"><prevlen> <encoding> <entry-data></span><br></pre></td></tr></table></figure> | |||
| <p>首先这个<code><prevlen></code>有两种情况,一种是前面的元素的长度,如果是小于等于 253的时候就用一个uint8_t 来表示前一元素的长度,如果大于的话他将占用五个字节,第一个字节是 254,即表示这个字节已经表示不下了,需要后面的四个字节帮忙表示<br><code><encoding></code>这个就比较复杂,把源码的注释放下面先看下</p> | |||
| <figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br></pre></td><td class="code"><pre><span class="line">* |00pppppp| - 1 byte</span><br><span class="line">* String value with length less than or equal to 63 bytes (6 bits).</span><br><span class="line">* "pppppp" represents the unsigned 6 bit length.</span><br><span class="line">* |01pppppp|qqqqqqqq| - 2 bytes</span><br><span class="line">* String value with length less than or equal to 16383 bytes (14 bits).</span><br><span class="line">* IMPORTANT: The 14 bit number is stored in big endian.</span><br><span class="line">* |10000000|qqqqqqqq|rrrrrrrr|ssssssss|tttttttt| - 5 bytes</span><br><span class="line">* String value with length greater than or equal to 16384 bytes.</span><br><span class="line">* Only the 4 bytes following the first byte represents the length</span><br><span class="line">* up to 32^2-1. The 6 lower bits of the first byte are not used and</span><br><span class="line">* are set to zero.</span><br><span class="line">* IMPORTANT: The 32 bit number is stored in big endian.</span><br><span class="line">* |11000000| - 3 bytes</span><br><span class="line">* Integer encoded as int16_t (2 bytes).</span><br><span class="line">* |11010000| - 5 bytes</span><br><span class="line">* Integer encoded as int32_t (4 bytes).</span><br><span class="line">* |11100000| - 9 bytes</span><br><span class="line">* Integer encoded as int64_t (8 bytes).</span><br><span class="line">* |11110000| - 4 bytes</span><br><span class="line">* Integer encoded as 24 bit signed (3 bytes).</span><br><span class="line">* |11111110| - 2 bytes</span><br><span class="line">* Integer encoded as 8 bit signed (1 byte).</span><br><span class="line">* |1111xxxx| - (with xxxx between 0000 and 1101) immediate 4 bit integer.</span><br><span class="line">* Unsigned integer from 0 to 12. The encoded value is actually from</span><br><span class="line">* 1 to 13 because 0000 and 1111 can not be used, so 1 should be</span><br><span class="line">* subtracted from the encoded 4 bit value to obtain the right value.</span><br><span class="line">* |11111111| - End of ziplist special entry.</span><br></pre></td></tr></table></figure> | |||
| <p>首先如果 encoding 的前两位是 00 的话代表这个元素是个 6 位的字符串,即直接将数据保存在 encoding 中,不消耗额外的<code><entry-data></code>,如果前两位是 01 的话表示是个 14 位的字符串,如果是 10 的话表示encoding 块之后的四个字节是存放字符串类型的数据,encoding 的剩余 6 位置 0。<br>如果 encoding 的前两位是 11 的话表示这是个整型,具体的如果后两位是00的话,表示后面是个2字节的 int16_t 类型,如果是01的话,后面是个4字节的int32_t,如果是10的话后面是8字节的int64_t,如果是 11 的话后面是 3 字节的有符号整型,这些都要最后 4 位都是 0 的情况噢<br>剩下当是<code>11111110</code>时,则表示是一个1 字节的有符号数,如果是 <code>1111xxxx</code>,其中<code>xxxx</code>在0000 到 1101 表示实际的 1 到 13,为啥呢,因为 0000 前面已经用过了,而 1110 跟 1111 也都有用了。<br>看个具体的例子(上下有点对不齐,将就看)</p> | |||
| <figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br></pre></td><td class="code"><pre><span class="line">[0f 00 00 00] [0c 00 00 00] [02 00] [00 f3] [02 f6] [ff]</span><br><span class="line">|**zlbytes***| |***zltail***| |*zllen*| |entry1 entry2| |zlend|</span><br></pre></td></tr></table></figure> | |||
| <p>第一部分代表整个 ziplist 有 15 个字节,zlbytes 自己占了 4 个 zltail 表示最后一个元素的偏移量,第 13 个字节起,zllen 表示有 2 个元素,第一个元素是<code>00f3</code>,00表示前一个元素长度是 0,本来前面就没元素(不过不知道这个能不能优化这一字节),然后是 f3,换成二进制就是11110011,对照上面的注释,是落在|1111xxxx|这个类型里,注意这个其实是用 0001 到 1101 也就是 1到 13 来表示 0到 12,所以 f3 应该就是 2,第一个元素是 2,第二个元素呢,02 代表前一个元素也就是刚才说的这个,占用 2 字节,f6 展开也是刚才的类型,实际是 5,ff 表示 ziplist 的结尾,所以这个 ziplist 里面是两个元素,2 跟 5</p> | |||
| </div> | |||
| <div class="popular-posts-header">Related Posts</div> | |||
| <ul class="popular-posts"> | |||
| <li class="popular-posts-item"> | |||
| <div class="popular-posts-title"><a href="/2020/01/10/redis数据结构介绍三/" rel="bookmark">redis数据结构介绍三-第三部分 整数集合</a></div> | |||
| </li> | |||
| <li class="popular-posts-item"> | |||
| <div class="popular-posts-title"><a href="/2020/01/04/redis数据结构介绍二/" rel="bookmark">redis数据结构介绍二-第二部分 跳表</a></div> | |||
| </li> | |||
| <li class="popular-posts-item"> | |||
| <div class="popular-posts-title"><a href="/2019/12/26/redis数据结构介绍/" rel="bookmark">redis数据结构介绍-第一部分 SDS,链表,字典</a></div> | |||
| </li> | |||
| </ul> | |||
| <div class="reward-container"> | |||
| <div>请我喝杯咖啡</div> | |||
| <button onclick="var qr = document.getElementById('qr'); qr.style.display = (qr.style.display === 'none') ? 'block' : 'none';"> | |||
| Donate | |||
| </button> | |||
| <div id="qr" style="display: none;"> | |||
| <div style="display: inline-block;"> | |||
| <img src="https://i.loli.net/2020/01/12/NUlWanT31E8LQGx.png" alt="Nicksxs WeChat Pay"> | |||
| <p>WeChat Pay</p> | |||
| </div> | |||
| <div style="display: inline-block;"> | |||
| <img src="https://ooo.0o0.ooo/2016/08/17/57b421e773057.jpg" alt="Nicksxs Alipay"> | |||
| <p>Alipay</p> | |||
| </div> | |||
| </div> | |||
| </div> | |||
| <div> | |||
| <ul class="post-copyright"> | |||
| <li class="post-copyright-author"> | |||
| <strong>Post author: </strong>Nicksxs | |||
| </li> | |||
| <li class="post-copyright-link"> | |||
| <strong>Post link: </strong> | |||
| <a href="https://nicksxs.me/2020/01/19/redis%E6%95%B0%E6%8D%AE%E7%BB%93%E6%9E%84%E4%BB%8B%E7%BB%8D%E5%9B%9B/" title="redis数据结构介绍四-第四部分 压缩表">https://nicksxs.me/2020/01/19/redis数据结构介绍四/</a> | |||
| </li> | |||
| <li class="post-copyright-license"> | |||
| <strong>Copyright Notice: </strong>All articles in this blog are licensed under <a href="https://creativecommons.org/licenses/by-nc-sa/4.0/" rel="noopener" target="_blank"><i class="fa fa-fw fa-creative-commons"></i>BY-NC-SA</a> unless stating additionally. | |||
| </li> | |||
| </ul> | |||
| </div> | |||
| <footer class="post-footer"> | |||
| <div class="post-tags"> | |||
| <a href="/tags/redis/" rel="tag"># redis</a> | |||
| <a href="/tags/%E6%95%B0%E6%8D%AE%E7%BB%93%E6%9E%84/" rel="tag"># 数据结构</a> | |||
| <a href="/tags/%E6%BA%90%E7%A0%81/" rel="tag"># 源码</a> | |||
| </div> | |||
| <div class="post-nav"> | |||
| <div class="post-nav-item"> | |||
| <a href="/2020/01/10/redis%E6%95%B0%E6%8D%AE%E7%BB%93%E6%9E%84%E4%BB%8B%E7%BB%8D%E4%B8%89/" rel="prev" title="redis数据结构介绍三-第三部分 整数集合"> | |||
| <i class="fa fa-chevron-left"></i> redis数据结构介绍三-第三部分 整数集合 | |||
| </a></div> | |||
| <div class="post-nav-item"></div> | |||
| </div> | |||
| </footer> | |||
| </article> | |||
| </div> | |||
| </div> | |||
| <div class="comments"> | |||
| <div id="disqus_thread"> | |||
| <noscript>Please enable JavaScript to view the comments powered by Disqus.</noscript> | |||
| </div> | |||
| </div> | |||
| <script> | |||
| window.addEventListener('tabs:register', () => { | |||
| let activeClass = CONFIG.comments.activeClass; | |||
| if (CONFIG.comments.storage) { | |||
| activeClass = localStorage.getItem('comments_active') || activeClass; | |||
| } | |||
| if (activeClass) { | |||
| let activeTab = document.querySelector(`a[href="#comment-${activeClass}"]`); | |||
| if (activeTab) { | |||
| activeTab.click(); | |||
| } | |||
| } | |||
| }); | |||
| if (CONFIG.comments.storage) { | |||
| window.addEventListener('tabs:click', event => { | |||
| if (!event.target.matches('.tabs-comment .tab-content .tab-pane')) return; | |||
| let commentClass = event.target.classList[1]; | |||
| localStorage.setItem('comments_active', commentClass); | |||
| }); | |||
| } | |||
| </script> | |||
| </div> | |||
| <div class="toggle sidebar-toggle"> | |||
| <span class="toggle-line toggle-line-first"></span> | |||
| <span class="toggle-line toggle-line-middle"></span> | |||
| <span class="toggle-line toggle-line-last"></span> | |||
| </div> | |||
| <aside class="sidebar"> | |||
| <div class="sidebar-inner"> | |||
| <ul class="sidebar-nav motion-element"> | |||
| <li class="sidebar-nav-toc"> | |||
| Table of Contents | |||
| </li> | |||
| <li class="sidebar-nav-overview"> | |||
| Overview | |||
| </li> | |||
| </ul> | |||
| <!--noindex--> | |||
| <div class="post-toc-wrap sidebar-panel"> | |||
| </div> | |||
| <!--/noindex--> | |||
| <div class="site-overview-wrap sidebar-panel"> | |||
| <div class="site-author motion-element" itemprop="author" itemscope itemtype="http://schema.org/Person"> | |||
| <img class="site-author-image" itemprop="image" alt="Nicksxs" | |||
| src="/uploads/avatar.jpg"> | |||
| <p class="site-author-name" itemprop="name">Nicksxs</p> | |||
| <div class="site-description" itemprop="description">learn from zero,技术博客,Nicksxs,史学森</div> | |||
| </div> | |||
| <div class="site-state-wrap motion-element"> | |||
| <nav class="site-state"> | |||
| <div class="site-state-item site-state-posts"> | |||
| <a href="/archives/"> | |||
| <span class="site-state-item-count">32</span> | |||
| <span class="site-state-item-name">posts</span> | |||
| </a> | |||
| </div> | |||
| <div class="site-state-item site-state-categories"> | |||
| <a href="/categories/"> | |||
| <span class="site-state-item-count">21</span> | |||
| <span class="site-state-item-name">categories</span></a> | |||
| </div> | |||
| <div class="site-state-item site-state-tags"> | |||
| <a href="/tags/"> | |||
| <span class="site-state-item-count">34</span> | |||
| <span class="site-state-item-name">tags</span></a> | |||
| </div> | |||
| </nav> | |||
| </div> | |||
| <div class="links-of-author motion-element"> | |||
| <span class="links-of-author-item"> | |||
| <a href="https://github.com/nicksxs" title="GitHub → https://github.com/nicksxs" rel="noopener" target="_blank"><i class="fa fa-fw fa-github"></i>GitHub</a> | |||
| </span> | |||
| <span class="links-of-author-item"> | |||
| <a href="mailto:nicksxs1202@gmail.com" title="E-Mail → mailto:nicksxs1202@gmail.com" rel="noopener" target="_blank"><i class="fa fa-fw fa-envelope"></i>E-Mail</a> | |||
| </span> | |||
| <span class="links-of-author-item"> | |||
| <a href="/atom.xml" title="RSS → /atom.xml"><i class="fa fa-fw fa-rss"></i>RSS</a> | |||
| </span> | |||
| </div> | |||
| <div class="cc-license motion-element" itemprop="license"> | |||
| <a href="https://creativecommons.org/licenses/by-nc-sa/4.0/" class="cc-opacity" rel="noopener" target="_blank"><img src="/images/cc-by-nc-sa.svg" alt="Creative Commons"></a> | |||
| </div> | |||
| <script type="text/javascript" charset="utf-8" src="/js/tagcloud.js"></script> | |||
| <script type="text/javascript" charset="utf-8" src="/js/tagcanvas.js"></script> | |||
| <div class="widget-wrap"> | |||
| <div id="myCanvasContainer" class="widget tagcloud"> | |||
| <canvas width="250" height="250" id="resCanvas" style="width=100%"> | |||
| <ul class="tag-list" itemprop="keywords"><li class="tag-list-item"><a class="tag-list-link" href="/tags/C/" rel="tag">C</a><span class="tag-list-count">1</span></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/C/" rel="tag">C++</a><span class="tag-list-count">2</span></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/Design-Patterns/" rel="tag">Design Patterns</a><span class="tag-list-count">1</span></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/Distributed-Lock/" rel="tag">Distributed Lock</a><span class="tag-list-count">1</span></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/JVM/" rel="tag">JVM</a><span class="tag-list-count">1</span></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/Java/" rel="tag">Java</a><span class="tag-list-count">1</span></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/Redis/" rel="tag">Redis</a><span class="tag-list-count">1</span></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/Singleton/" rel="tag">Singleton</a><span class="tag-list-count">1</span></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/aqs/" rel="tag">aqs</a><span class="tag-list-count">1</span></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/c/" rel="tag">c++</a><span class="tag-list-count">14</span></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/cluster/" rel="tag">cluster</a><span class="tag-list-count">1</span></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/docker/" rel="tag">docker</a><span class="tag-list-count">1</span></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/hadoop/" rel="tag">hadoop</a><span class="tag-list-count">1</span></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/im/" rel="tag">im</a><span class="tag-list-count">1</span></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/java/" rel="tag">java</a><span class="tag-list-count">1</span></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/leetcode/" rel="tag">leetcode</a><span class="tag-list-count">13</span></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/mfc/" rel="tag">mfc</a><span class="tag-list-count">2</span></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/mq/" rel="tag">mq</a><span class="tag-list-count">1</span></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/mysql/" rel="tag">mysql</a><span class="tag-list-count">1</span></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/nginx/" rel="tag">nginx</a><span class="tag-list-count">1</span></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/openresty/" rel="tag">openresty</a><span class="tag-list-count">1</span></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/php/" rel="tag">php</a><span class="tag-list-count">2</span></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/python/" rel="tag">python</a><span class="tag-list-count">1</span></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/redis/" rel="tag">redis</a><span class="tag-list-count">4</span></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/spark/" rel="tag">spark</a><span class="tag-list-count">1</span></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/swoole/" rel="tag">swoole</a><span class="tag-list-count">1</span></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/websocket/" rel="tag">websocket</a><span class="tag-list-count">1</span></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/%E5%88%86%E5%B8%83%E5%BC%8F%E9%94%81/" rel="tag">分布式锁</a><span class="tag-list-count">1</span></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/%E5%8D%95%E4%BE%8B/" rel="tag">单例</a><span class="tag-list-count">1</span></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/%E5%8D%9A%E5%AE%A2%EF%BC%8C%E6%96%87%E7%AB%A0/" rel="tag">博客,文章</a><span class="tag-list-count">1</span></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/%E6%95%B0%E6%8D%AE%E7%BB%93%E6%9E%84/" rel="tag">数据结构</a><span class="tag-list-count">4</span></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/%E6%BA%90%E7%A0%81/" rel="tag">源码</a><span class="tag-list-count">4</span></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/%E8%AE%BE%E8%AE%A1%E6%A8%A1%E5%BC%8F/" rel="tag">设计模式</a><span class="tag-list-count">1</span></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/%E8%AF%BB%E5%90%8E%E6%84%9F/" rel="tag">读后感</a><span class="tag-list-count">1</span></li></ul> | |||
| </canvas> | |||
| </div> | |||
| </div> | |||
| <div class="links-of-blogroll motion-element"> | |||
| <div class="links-of-blogroll-title"> | |||
| <i class="fa fa-fw fa-link"></i> | |||
| Links | |||
| </div> | |||
| <ul class="links-of-blogroll-list"> | |||
| <li class="links-of-blogroll-item"> | |||
| <a href="http://www.zipperary.com/" title="http://www.zipperary.com/" rel="noopener" target="_blank">Zippera's blog</a> | |||
| </li> | |||
| <li class="links-of-blogroll-item"> | |||
| <a href="http://x20a.xyz/" title="http://x20a.xyz/" rel="noopener" target="_blank">Freedom</a> | |||
| </li> | |||
| <li class="links-of-blogroll-item"> | |||
| <a href="http://samuel.group/" title="http://samuel.group/" rel="noopener" target="_blank">sfwtt</a> | |||
| </li> | |||
| <li class="links-of-blogroll-item"> | |||
| <a href="http://blog.leanote.com/buru" title="http://blog.leanote.com/buru" rel="noopener" target="_blank">bruce</a> | |||
| </li> | |||
| <li class="links-of-blogroll-item"> | |||
| <a href="http://m2shad0w.com/" title="http://m2shad0w.com/" rel="noopener" target="_blank">m2shad0w</a> | |||
| </li> | |||
| <li class="links-of-blogroll-item"> | |||
| <a href="http://www.programcat.com/" title="http://www.programcat.com" rel="noopener" target="_blank">程序喵的厨房</a> | |||
| </li> | |||
| </ul> | |||
| </div> | |||
| </div> | |||
| </div> | |||
| </aside> | |||
| <div id="sidebar-dimmer"></div> | |||
| </div> | |||
| </main> | |||
| <footer class="footer"> | |||
| <div class="footer-inner"> | |||
| <div class="copyright"> | |||
| © | |||
| <span itemprop="copyrightYear">2020</span> | |||
| <span class="with-love"> | |||
| <i class="fa fa-user"></i> | |||
| </span> | |||
| <span class="author" itemprop="copyrightHolder">Nicksxs</span> | |||
| </div> | |||
| </div> | |||
| </footer> | |||
| </div> | |||
| <script src="/lib/anime.min.js"></script> | |||
| <script src="//cdn.jsdelivr.net/npm/jquery@3/dist/jquery.min.js"></script> | |||
| <script src="//cdn.jsdelivr.net/gh/fancyapps/fancybox@3/dist/jquery.fancybox.min.js"></script> | |||
| <script src="//cdn.jsdelivr.net/npm/lozad@1/dist/lozad.min.js"></script> | |||
| <script src="/lib/velocity/velocity.min.js"></script> | |||
| <script src="/lib/velocity/velocity.ui.min.js"></script> | |||
| <script src="/js/utils.js"></script> | |||
| <script src="/js/motion.js"></script> | |||
| <script src="/js/schemes/pisces.js"></script> | |||
| <script src="/js/next-boot.js"></script> | |||
| <script> | |||
| (function(){ | |||
| var bp = document.createElement('script'); | |||
| var curProtocol = window.location.protocol.split(':')[0]; | |||
| bp.src = (curProtocol === 'https') ? 'https://zz.bdstatic.com/linksubmit/push.js' : 'http://push.zhanzhang.baidu.com/push.js'; | |||
| var s = document.getElementsByTagName("script")[0]; | |||
| s.parentNode.insertBefore(bp, s); | |||
| })(); | |||
| </script> | |||
| <script src="//cdn.jsdelivr.net/npm/quicklink@1/dist/quicklink.umd.js"></script> | |||
| <script> | |||
| window.addEventListener('load', () => { | |||
| quicklink({ | |||
| timeout: 3000, | |||
| priority: true, | |||
| ignores: [uri => uri.includes('#'),uri => uri == 'https://nicksxs.me/2020/01/19/redis%E6%95%B0%E6%8D%AE%E7%BB%93%E6%9E%84%E4%BB%8B%E7%BB%8D%E5%9B%9B/',] | |||
| }); | |||
| }); | |||
| </script> | |||
| <script> | |||
| function loadCount() { | |||
| var d = document, s = d.createElement('script'); | |||
| s.src = 'https://nicksxs.disqus.com/count.js'; | |||
| s.id = 'dsq-count-scr'; | |||
| (d.head || d.body).appendChild(s); | |||
| } | |||
| // defer loading until the whole page loading is completed | |||
| window.addEventListener('load', loadCount, false); | |||
| </script> | |||
| <script> | |||
| NexT.utils.loadComments(document.querySelector('#disqus_thread'), () => { | |||
| if (window.DISQUS) { | |||
| DISQUS.reset({ | |||
| reload: true, | |||
| config: {page: { | |||
| url: "https://nicksxs.me/2020/01/19/redis%E6%95%B0%E6%8D%AE%E7%BB%93%E6%9E%84%E4%BB%8B%E7%BB%8D%E5%9B%9B/", | |||
| identifier: "2020/01/19/redis数据结构介绍四/", | |||
| title: "redis数据结构介绍四-第四部分 压缩表" | |||
| } | |||
| } | |||
| }); | |||
| } else { | |||
| var d = document, s = d.createElement('script'); | |||
| s.src = 'https://nicksxs.disqus.com/embed.js'; | |||
| s.setAttribute('data-timestamp', '' + +new Date()); | |||
| (d.head || d.body).appendChild(s); | |||
| } | |||
| }); | |||
| </script> | |||
| </body> | |||
| </html> | |||