{"id":7656,"date":"2026-08-17T10:05:44","date_gmt":"2026-08-17T02:05:44","guid":{"rendered":"https:\/\/i007.cc\/wordpress\/?p=7656"},"modified":"2026-08-17T10:05:44","modified_gmt":"2026-08-17T02:05:44","slug":"%e4%b8%ba%e4%bb%80%e4%b9%88-zset-%e7%94%a8%e8%b7%b3%e8%a1%a8%e8%80%8c%e4%b8%8d%e7%94%a8%e7%ba%a2%e9%bb%91%e6%a0%91","status":"publish","type":"post","link":"https:\/\/i007.cc\/wordpress\/archives\/7656","title":{"rendered":"\u4e3a\u4ec0\u4e48 Zset \u7528\u8df3\u8868\u800c\u4e0d\u7528\u7ea2\u9ed1\u6811"},"content":{"rendered":"<div data-rs-index=\"5\" data-index=\"5\" data-testid=\"transcript-row\">\n<div class=\"rounded-lg focus-visible:shadow-focus focus-visible:outline-hidden\" tabindex=\"0\" role=\"article\" aria-setsize=\"8\" aria-posinset=\"6\" aria-label=\"Message 6 of 8\">\n<div data-test-render-count=\"2\">\n<div class=\"group group\/message-row\">\n<div class=\"group relative relative pb-[var(--msg-assistant-pb,0.75rem)]\" data-is-streaming=\"false\">\n<div class=\"font-claude-response relative leading-[1.65rem] [&amp;_pre&gt;div]:bg-bg-000\/50 [&amp;_pre&gt;div]:border-0.5 [&amp;_pre&gt;div]:border-border-400 [&amp;_.ignore-pre-bg&gt;div]:bg-transparent [&amp;_.standard-markdown_:is(p,blockquote,h1,h2,h3,h4,h5,h6)]:pl-[var(--msg-text-inset,0.5rem)] [&amp;_.standard-markdown_:is(p,blockquote,ul,ol,h1,h2,h3,h4,h5,h6)]:pr-8 [&amp;_.progressive-markdown_:is(p,blockquote,h1,h2,h3,h4,h5,h6)]:pl-[var(--msg-text-inset,0.5rem)] [&amp;_.progressive-markdown_:is(p,blockquote,ul,ol,h1,h2,h3,h4,h5,h6)]:pr-8\">\n<div class=\"standard-markdown grid-cols-1 grid [&amp;_&gt;_*]:min-w-0 gap-3 [&amp;_&gt;_*:last-child]:mb-0 print:block print:[&amp;_&gt;_:where(:not(:first-child))]:mt-3 standard-markdown\">\n<p class=\"font-claude-response-body break-words whitespace-normal\" dir=\"ltr\">\u8fd9\u4e2a\u95ee\u9898 Redis \u4f5c\u8005 antirez \u5728\u90ae\u4ef6\u5217\u8868\u91cc\u4eb2\u81ea\u56de\u7b54\u8fc7\uff0c\u6838\u5fc3\u4e0d\u662f&#8221;\u8df3\u8868\u6027\u80fd\u78be\u538b\u7ea2\u9ed1\u6811&#8221;\uff0c\u4e24\u8005\u7684\u5e73\u5747\u65f6\u95f4\u590d\u6742\u5ea6\u90fd\u662f O(log n)\uff0c\u91cf\u7ea7\u4e0a\u662f\u4e00\u6837\u7684\u3002\u771f\u6b63\u7684\u539f\u56e0\u66f4\u504f\u5de5\u7a0b\u6743\u8861,\u53ef\u4ee5\u4ece\u8fd9\u51e0\u4e2a\u89d2\u5ea6\u770b\u3002<\/p>\n<h3 class=\"mt-3 -mb-1 text-[1.125rem] font-bold\" dir=\"ltr\">\u8303\u56f4\u67e5\u8be2\u662f\u8df3\u8868\u7684\u5929\u7136\u4f18\u52bf<\/h3>\n<p class=\"font-claude-response-body break-words whitespace-normal\" dir=\"ltr\">Zset \u6700\u5e38\u7528\u7684\u64cd\u4f5c\u4e4b\u4e00\u662f <code class=\"bg-text-200\/5 border border-0.5 border-border-300 text-danger-000 whitespace-pre-wrap rounded-[0.4rem] px-1 py-px text-[0.9rem]\">ZRANGEBYSCORE<\/code>\u3001<code class=\"bg-text-200\/5 border border-0.5 border-border-300 text-danger-000 whitespace-pre-wrap rounded-[0.4rem] px-1 py-px text-[0.9rem]\">ZRANGE<\/code> \u8fd9\u7c7b\u6309 score \u533a\u95f4\u53d6\u4e00\u6279\u5143\u7d20\u7684\u64cd\u4f5c\u3002\u8df3\u8868\u672c\u8d28\u4e0a\u662f\u4e00\u4e2a\u5e26\u591a\u7ea7\u7d22\u5f15\u7684\u6709\u5e8f\u94fe\u8868,\u627e\u5230\u533a\u95f4\u8d77\u70b9\u540e,\u987a\u7740\u6700\u5e95\u5c42\uff08level 0)\u7684\u94fe\u8868\u6307\u9488\u4e00\u8def\u904d\u5386\u4e0b\u53bb\u5c31\u884c\u4e86,\u590d\u6742\u5ea6\u662f O(log n + m)\uff08m \u662f\u533a\u95f4\u5185\u5143\u7d20\u4e2a\u6570),\u4ee3\u7801\u903b\u8f91\u975e\u5e38\u76f4\u89c2\u3002<\/p>\n<p class=\"font-claude-response-body break-words whitespace-normal\" dir=\"ltr\">\u7ea2\u9ed1\u6811\u867d\u7136\u4e2d\u5e8f\u904d\u5386\u4e5f\u80fd\u5f97\u5230\u6709\u5e8f\u5e8f\u5217,\u4f46\u6811\u7ed3\u6784\u505a&#8221;\u4ece\u67d0\u4e2a\u8282\u70b9\u5f00\u59cb\u8fde\u7eed\u53d6 m \u4e2a&#8221;\u8fd9\u79cd\u64cd\u4f5c\u5e76\u4e0d\u5929\u7136,\u8981\u4e48\u7ef4\u62a4\u989d\u5916\u7684\u7236\u6307\u9488\u5f80\u4e0a\u56de\u6eaf\u518d\u5f80\u4e0b\u627e,\u8981\u4e48\u7528\u6808\u6a21\u62df\u4e2d\u5e8f\u904d\u5386,\u5b9e\u73b0\u590d\u6742\u5ea6\u548c\u4ee3\u7801\u53ef\u8bfb\u6027\u90fd\u4e0d\u5982\u8df3\u8868\u3002<\/p>\n<h3 class=\"mt-3 -mb-1 text-[1.125rem] font-bold\" dir=\"ltr\">\u5b9e\u73b0\u590d\u6742\u5ea6\u548c\u6b63\u786e\u6027<\/h3>\n<p class=\"font-claude-response-body break-words whitespace-normal\" dir=\"ltr\">\u7ea2\u9ed1\u6811\u7684\u63d2\u5165\u3001\u5220\u9664\u4e3a\u4e86\u7ef4\u6301&#8221;\u7ea2\u9ed1\u6027\u8d28&#8221;\uff08\u6bd4\u5982\u4efb\u610f\u8def\u5f84\u9ed1\u8282\u70b9\u6570\u76f8\u540c\uff09,\u9700\u8981\u5904\u7406\u591a\u79cd\u65cb\u8f6c\uff08\u5de6\u65cb\/\u53f3\u65cb\uff09\u548c\u53d8\u8272\u7684\u573a\u666f,\u60c5\u51b5\u5206\u652f\u591a,\u5bb9\u6613\u5199\u9519,\u8c03\u8bd5\u548c\u7ef4\u62a4\u6210\u672c\u9ad8\u3002<\/p>\n<p class=\"font-claude-response-body break-words whitespace-normal\" dir=\"ltr\">\u8df3\u8868\u7684\u63d2\u5165\u53ea\u9700\u8981:\u968f\u673a\u751f\u6210\u4e00\u4e2a\u5c42\u6570,\u7136\u540e\u5728\u6bcf\u4e00\u5c42\u627e\u5230\u63d2\u5165\u4f4d\u7f6e\u4fee\u6539\u6307\u9488,\u4e0d\u6d89\u53ca\u5168\u5c40\u7684\u91cd\u65b0\u5e73\u8861,\u903b\u8f91\u7b80\u5355\u5f88\u591a,\u51fa bug \u7684\u6982\u7387\u66f4\u4f4e\u3002\u5bf9\u4e8e Redis \u8fd9\u79cd\u8981\u4fdd\u8bc1\u7a33\u5b9a\u6027\u7684\u57fa\u7840\u8bbe\u65bd\u6765\u8bf4,&#8221;\u7b80\u5355\u3001\u597d\u7ef4\u62a4\u3001\u4e0d\u5bb9\u6613\u51fa\u9519&#8221;\u672c\u8eab\u5c31\u662f\u5f88\u91cd\u8981\u7684\u5de5\u7a0b\u8003\u91cf,\u8fd9\u4e5f\u662f antirez \u539f\u8bdd\u91cc\u63d0\u5230\u7684\u7406\u7531\u4e4b\u4e00:\u8df3\u8868\u5b9e\u73b0\u8d77\u6765\u8db3\u591f\u7b80\u5355,\u800c\u4e14\u6539\u8d77\u6765\u4e5f\u5bb9\u6613,\u5bf9\u53ef\u8bfb\u6027\u53cb\u597d\u3002<\/p>\n<h3 class=\"mt-3 -mb-1 text-[1.125rem] font-bold\" dir=\"ltr\">\u5185\u5b58\u4e0e\u6027\u80fd\u662f\u540c\u4e00\u91cf\u7ea7,\u8df3\u8868\u4e0d\u5403\u4e8f<\/h3>\n<p class=\"font-claude-response-body break-words whitespace-normal\" dir=\"ltr\">\u8df3\u8868\u6bcf\u4e2a\u8282\u70b9\u8981\u5b58\u591a\u5c42\u6307\u9488,\u5e73\u5747\u4e0b\u6765\u6bcf\u4e2a\u8282\u70b9\u7684\u671f\u671b\u5c42\u6570\u662f O(log n)\uff08Redis \u7528\u56fa\u5b9a\u6982\u7387 1\/4 \u51b3\u5b9a\u662f\u5426\u5347\u5c42),\u6574\u4f53\u5185\u5b58\u5f00\u9500\u548c\u7ea2\u9ed1\u6811\u7684\u7236\u5b50\u6307\u9488+\u989c\u8272\u6807\u8bb0\u8fd9\u4e9b\u989d\u5916\u5f00\u9500\u662f\u540c\u4e00\u6570\u91cf\u7ea7,\u5e76\u4e0d\u5b58\u5728\u8df3\u8868\u660e\u663e\u66f4\u8d39\u5185\u5b58\u7684\u95ee\u9898\u3002\u800c\u4e14\u8df3\u8868\u7684\u5e38\u6570\u56e0\u5b50\u8f83\u5c0f(\u6ca1\u6709\u65cb\u8f6c\u64cd\u4f5c\u7684\u5f00\u9500),\u5b9e\u9645\u5de5\u7a0b\u8868\u73b0\u4e0d\u6bd4\u7ea2\u9ed1\u6811\u5dee\u3002<\/p>\n<h3 class=\"mt-3 -mb-1 text-[1.125rem] font-bold\" dir=\"ltr\">\u987a\u5e26\u4e00\u63d0:Zset \u4e0d\u662f\u5355\u9760\u8df3\u8868<\/h3>\n<p class=\"font-claude-response-body break-words whitespace-normal\" dir=\"ltr\">\u5bb9\u6613\u88ab\u5ffd\u7565\u7684\u4e00\u70b9\u662f,Zset \u5728\u6570\u636e\u91cf\u8f83\u5927\u65f6,\u5185\u90e8\u5176\u5b9e\u662f\u8df3\u8868\uff08skiplist\uff09+ \u54c8\u5e0c\u8868\uff08dict\uff09\u4e24\u79cd\u7ed3\u6784\u7ec4\u5408\u4f7f\u7528\uff1adict \u8d1f\u8d23 member \u2192 score \u7684\u6620\u5c04,\u4fdd\u8bc1 <code class=\"bg-text-200\/5 border border-0.5 border-border-300 text-danger-000 whitespace-pre-wrap rounded-[0.4rem] px-1 py-px text-[0.9rem]\">ZSCORE<\/code>\uff08\u6309\u6210\u5458\u67e5\u5206\u6570\uff09\u662f O(1);skiplist \u8d1f\u8d23\u6309 score \u6392\u5e8f,\u652f\u6491 <code class=\"bg-text-200\/5 border border-0.5 border-border-300 text-danger-000 whitespace-pre-wrap rounded-[0.4rem] px-1 py-px text-[0.9rem]\">ZRANK<\/code>\u3001<code class=\"bg-text-200\/5 border border-0.5 border-border-300 text-danger-000 whitespace-pre-wrap rounded-[0.4rem] px-1 py-px text-[0.9rem]\">ZRANGE<\/code> \u8fd9\u7c7b\u6709\u5e8f\u533a\u95f4\u64cd\u4f5c\u3002\u4e24\u8005\u5171\u4eab\u540c\u4e00\u4efd\u5143\u7d20,\u53ea\u662f\u7d22\u5f15\u65b9\u5f0f\u4e0d\u540c,\u5206\u522b\u89e3\u51b3&#8221;\u70b9\u67e5\u8be2\u5feb&#8221;\u548c&#8221;\u8303\u56f4\u67e5\u8be2\u5feb&#8221;\u8fd9\u4e24\u4e2a\u4e0d\u540c\u7684\u9700\u6c42,\u5355\u72ec\u7528\u54ea\u4e00\u79cd\u90fd\u8986\u76d6\u4e0d\u4e86 Zset \u7684\u5168\u90e8\u64cd\u4f5c\u573a\u666f\u3002<\/p>\n<p class=\"font-claude-response-body break-words whitespace-normal\" dir=\"ltr\">\u800c\u5f53 Zset \u5143\u7d20\u5c11\uff08\u9ed8\u8ba4 128 \u4e2a\u4ee5\u5185)\u4e14\u6bcf\u4e2a\u5143\u7d20\u957f\u5ea6\u4e5f\u5c0f\uff08\u9ed8\u8ba4 64 \u5b57\u8282\u4ee5\u5185)\u65f6,Redis \u4f1a\u7528 ziplist\/listpack \u8fd9\u79cd\u66f4\u7701\u5185\u5b58\u7684\u538b\u7f29\u5217\u8868\u7f16\u7801,\u6b64\u65f6\u6ca1\u6709\u8df3\u8868\u548c\u54c8\u5e0c\u8868,\u662f\u7ebf\u6027\u904d\u5386,\u56e0\u4e3a\u6570\u636e\u91cf\u5c0f,O(n) \u904d\u5386\u6bd4\u7ef4\u62a4\u590d\u6742\u7ed3\u6784\u66f4\u5212\u7b97,\u8d85\u8fc7\u9608\u503c\u624d\u8f6c\u6362\u6210 skiplist+dict \u7684\u7ec4\u5408\u3002<\/p>\n<h3 class=\"mt-3 -mb-1 text-[1.125rem] font-bold\" dir=\"ltr\">\u4e00\u53e5\u8bdd\u603b\u7ed3<\/h3>\n<p class=\"font-claude-response-body break-words whitespace-normal\" dir=\"ltr\">\u8df3\u8868\u548c\u7ea2\u9ed1\u6811\u5728\u65f6\u95f4\u590d\u6742\u5ea6\u4e0a\u6253\u5e73,\u4f46\u8df3\u8868\u5728<strong>\u8303\u56f4\u67e5\u8be2\u5b9e\u73b0\u7684\u76f4\u89c2\u6027<\/strong>\u548c<strong>\u4ee3\u7801\u5b9e\u73b0\/\u7ef4\u62a4\u7684\u7b80\u5355\u6027<\/strong>\u4e0a\u660e\u663e\u5360\u4f18,\u8fd9\u662f Redis \u56e2\u961f\u6743\u8861\u540e\u7684\u9009\u62e9,\u4e0d\u662f\u7eaf\u7cb9\u4e3a\u4e86\u8ffd\u6c42\u6781\u81f4\u6027\u80fd\u3002<\/p>\n<p class=\"font-claude-response-body break-words whitespace-normal\" dir=\"ltr\">\u5982\u679c\u4f60\u611f\u5174\u8da3,\u8fd8\u53ef\u4ee5\u5f80\u4e0b\u804a\u8df3\u8868\u7684\u5c42\u6570\u662f\u600e\u4e48\u968f\u673a\u751f\u6210\u7684\uff08\u4e3a\u4ec0\u4e48\u6982\u7387\u53d6 1\/4 \u800c\u4e0d\u662f 1\/2)\u3001Zset \u7f16\u7801\u8f6c\u6362\u7684\u5177\u4f53\u9608\u503c\u914d\u7f6e,\u6216\u8005\u5bf9\u6bd4\u4e00\u4e0b Redis \u7528\u8df3\u8868\u548c LevelDB\/RocksDB \u7528 LSM-Tree \u8fd9\u79cd\u8bbe\u8ba1\u53d6\u820d\u7684\u5dee\u5f02\u3002<\/p>\n<\/div>\n<\/div>\n<\/div>\n<\/div>\n<\/div>\n<\/div>\n<\/div>\n<div data-rs-index=\"6\" data-index=\"6\" data-testid=\"transcript-row\">\n<div class=\"rounded-lg focus-visible:shadow-focus focus-visible:outline-hidden\" tabindex=\"-1\" role=\"article\" aria-setsize=\"8\" aria-posinset=\"7\" aria-label=\"Message 7 of 8\">\n<div data-test-render-count=\"2\">\n<div class=\"mb-1 mt-[var(--msg-gap,1.5rem)] group group\/message-row\">\n<div class=\"flex flex-col items-end gap-1\">\n<div class=\"group\/message-row flex min-w-0 flex-col items-end gap-xs font-sans ms-auto max-w-[85%] cds-um-enter\" data-cds=\"UserMessage\">\n<div class=\"relative flex max-w-full min-w-0 flex-col gap-xs rounded-card px-lg py-md text-heading break-words select-text text-primary bg-neutral\">\n<div id=\"_r_of_\" class=\"\">\n<div>\n<div class=\"grid grid-cols-1 gap-2 relative [&amp;_ul]:!space-y-0 [&amp;_ol]:!space-y-0 [&amp;_ul]:pl-8 [&amp;_ol]:pl-8\" data-testid=\"user-message\">\n<p class=\"whitespace-pre-wrap break-words\" dir=\"ltr\">\u6982\u7387\u4e0d\u662f1\/2\u4e48\uff1f\u4e3a\u4ec0\u4e48\u662f1\/4\uff1f<\/p>\n<\/div>\n<\/div>\n<\/div>\n<\/div>\n<\/div>\n<div class=\"max-w-[85%]\"><\/div>\n<\/div>\n<\/div>\n<\/div>\n<\/div>\n<\/div>\n<div data-rs-index=\"7\" data-index=\"7\" data-testid=\"transcript-row\" data-last-message=\"true\">\n<div class=\"rounded-lg focus-visible:shadow-focus focus-visible:outline-hidden\" tabindex=\"-1\" role=\"article\" aria-setsize=\"8\" aria-posinset=\"8\" aria-label=\"Message 8 of 8\">\n<div data-test-render-count=\"1\">\n<div class=\"group group\/message-row\">\n<div class=\"group relative relative pb-[var(--msg-assistant-pb,0.75rem)]\" data-is-streaming=\"false\">\n<div class=\"font-claude-response relative leading-[1.65rem] [&amp;_pre&gt;div]:bg-bg-000\/50 [&amp;_pre&gt;div]:border-0.5 [&amp;_pre&gt;div]:border-border-400 [&amp;_.ignore-pre-bg&gt;div]:bg-transparent [&amp;_.standard-markdown_:is(p,blockquote,h1,h2,h3,h4,h5,h6)]:pl-[var(--msg-text-inset,0.5rem)] [&amp;_.standard-markdown_:is(p,blockquote,ul,ol,h1,h2,h3,h4,h5,h6)]:pr-8 [&amp;_.progressive-markdown_:is(p,blockquote,h1,h2,h3,h4,h5,h6)]:pl-[var(--msg-text-inset,0.5rem)] [&amp;_.progressive-markdown_:is(p,blockquote,ul,ol,h1,h2,h3,h4,h5,h6)]:pr-8\">\n<div>\n<div class=\"standard-markdown grid-cols-1 grid [&amp;_&gt;_*]:min-w-0 gap-3 [&amp;_&gt;_*:last-child]:mb-0 print:block print:[&amp;_&gt;_:where(:not(:first-child))]:mt-3 standard-markdown\">\n<h2 class=\"mt-3 -mb-1 text-[1.375rem] font-bold\" dir=\"ltr\">\u6982\u7387\u4e3a\u4ec0\u4e48\u662f 1\/4 \u800c\u4e0d\u662f 1\/2<\/h2>\n<p class=\"font-claude-response-body break-words whitespace-normal\" dir=\"ltr\">\u5148\u7ea0\u6b63\u4e00\u4e0b\u524d\u63d0\uff1a\u8df3\u8868\u7406\u8bba\u4e0a p \u53d6\u591a\u5c11\u90fd\u53ef\u4ee5,William Pugh \u5728\u63d0\u51fa\u8df3\u8868\u7684\u8bba\u6587\u91cc\u786e\u5b9e\u4e3e\u4e86 p=1\/2 \u7684\u4f8b\u5b50\u4f5c\u4e3a\u6700\u76f4\u89c2\u7684\u8bf4\u660e,\u4f46\u4ed6\u540c\u65f6\u5206\u6790\u8bba\u8bc1\u4e86 p=1\/4\uff08\u751a\u81f3 1\/e\u22480.37)\u5728\u7efc\u5408\u6027\u80fd\u4e0a\u5176\u5b9e\u66f4\u4f18\u3002Redis \u5728 <code class=\"bg-text-200\/5 border border-0.5 border-border-300 text-danger-000 whitespace-pre-wrap rounded-[0.4rem] px-1 py-px text-[0.9rem]\">t_zset.c<\/code> \u91cc\u5b9a\u4e49\u7684 <code class=\"bg-text-200\/5 border border-0.5 border-border-300 text-danger-000 whitespace-pre-wrap rounded-[0.4rem] px-1 py-px text-[0.9rem]\">ZSKIPLIST_P<\/code> \u5c31\u662f 0.25,\u4e0d\u662f 1\/2,\u8fd9\u662f\u6709\u610f\u9009\u7684,\u4e0d\u662f\u7b14\u8bef\u3002<\/p>\n<h3 class=\"mt-3 -mb-1 text-[1.125rem] font-bold\" dir=\"ltr\">\u5173\u952e\u6743\u8861:\u7a7a\u95f4 vs \u65f6\u95f4<\/h3>\n<p class=\"font-claude-response-body break-words whitespace-normal\" dir=\"ltr\">\u8df3\u8868\u6bcf\u4e2a\u8282\u70b9\u4f1a\u4e0d\u4f1a\u5f80\u4e0a\u4e00\u5c42\u5347,\u662f\u6309\u6982\u7387 p \u72ec\u7acb\u629b\u786c\u5e01\u51b3\u5b9a\u7684\uff08\u80fd\u5230\u7b2c 1 \u5c42\u518d\u629b\u4e00\u6b21\u51b3\u5b9a\u80fd\u4e0d\u80fd\u5230\u7b2c 2 \u5c42,\u4ee5\u6b64\u7c7b\u63a8)\u3002\u8fd9\u5e26\u6765\u4e24\u4e2a\u76f4\u63a5\u540e\u679c:<\/p>\n<p class=\"font-claude-response-body break-words whitespace-normal\" dir=\"ltr\">\u5e73\u5747\u6bcf\u4e2a\u8282\u70b9\u5360\u7528\u7684\u6307\u9488\u6570\uff08\u4e5f\u5c31\u662f\u5185\u5b58\u5f00\u9500\uff09,\u671f\u671b\u503c\u662f <code class=\"bg-text-200\/5 border border-0.5 border-border-300 text-danger-000 whitespace-pre-wrap rounded-[0.4rem] px-1 py-px text-[0.9rem]\">1\/(1-p)<\/code>\uff1a<\/p>\n<ul class=\"[li_&amp;]:mb-0 [li_&amp;]:mt-1 [li_&amp;]:gap-1 [&amp;:not(:last-child)_ul]:pb-1 [&amp;:not(:last-child)_ol]:pb-1 list-disc flex flex-col gap-1 pl-8 mb-3 print:block print:space-y-1\" dir=\"ltr\">\n<li class=\"font-claude-response-body whitespace-normal break-words pl-2\">p = 1\/2 \u65f6,<code class=\"bg-text-200\/5 border border-0.5 border-border-300 text-danger-000 whitespace-pre-wrap rounded-[0.4rem] px-1 py-px text-[0.9rem]\">1\/(1-0.5) = 2<\/code>,\u5e73\u5747\u6bcf\u4e2a\u8282\u70b9\u8981\u7ef4\u62a4 2 \u4e2a\u6307\u9488;<\/li>\n<li class=\"font-claude-response-body whitespace-normal break-words pl-2\">p = 1\/4 \u65f6,<code class=\"bg-text-200\/5 border border-0.5 border-border-300 text-danger-000 whitespace-pre-wrap rounded-[0.4rem] px-1 py-px text-[0.9rem]\">1\/(1-0.25) \u2248 1.33<\/code>,\u5e73\u5747\u6bcf\u4e2a\u8282\u70b9\u53ea\u8981\u7ef4\u62a4\u7ea6 1.33 \u4e2a\u6307\u9488\u3002<\/li>\n<\/ul>\n<p class=\"font-claude-response-body break-words whitespace-normal\" dir=\"ltr\">\u4e5f\u5c31\u662f\u8bf4,\u540c\u6837\u89c4\u6a21\u7684\u6570\u636e,p=1\/4 \u6bd4 p=1\/2 \u5927\u6982\u80fd\u7701\u4e0b 1\/3 \u7684\u6307\u9488\u5185\u5b58\u5f00\u9500\u3002<\/p>\n<p class=\"font-claude-response-body break-words whitespace-normal\" dir=\"ltr\">\u518d\u770b\u67e5\u627e\u6548\u7387,Pugh \u8bba\u6587\u7ed9\u51fa\u7684\u671f\u671b\u67e5\u627e\u6bd4\u8f83\u6b21\u6570\u8fd1\u4f3c\u662f <code class=\"bg-text-200\/5 border border-0.5 border-border-300 text-danger-000 whitespace-pre-wrap rounded-[0.4rem] px-1 py-px text-[0.9rem]\">log_{1\/p}(n) \/ p<\/code>\uff1a<\/p>\n<ul class=\"[li_&amp;]:mb-0 [li_&amp;]:mt-1 [li_&amp;]:gap-1 [&amp;:not(:last-child)_ul]:pb-1 [&amp;:not(:last-child)_ol]:pb-1 list-disc flex flex-col gap-1 pl-8 mb-3 print:block print:space-y-1\" dir=\"ltr\">\n<li class=\"font-claude-response-body whitespace-normal break-words pl-2\">p = 1\/2 \u65f6\u7ea6\u7b49\u4e8e <code class=\"bg-text-200\/5 border border-0.5 border-border-300 text-danger-000 whitespace-pre-wrap rounded-[0.4rem] px-1 py-px text-[0.9rem]\">2 \u00b7 log\u2082n<\/code>;<\/li>\n<li class=\"font-claude-response-body whitespace-normal break-words pl-2\">p = 1\/4 \u65f6\u7ea6\u7b49\u4e8e <code class=\"bg-text-200\/5 border border-0.5 border-border-300 text-danger-000 whitespace-pre-wrap rounded-[0.4rem] px-1 py-px text-[0.9rem]\">2 \u00b7 log\u2082n<\/code>\uff08<code class=\"bg-text-200\/5 border border-0.5 border-border-300 text-danger-000 whitespace-pre-wrap rounded-[0.4rem] px-1 py-px text-[0.9rem]\">log\u2084n \u00b7 4 = (log\u2082n\/2)\u00b74 = 2\u00b7log\u2082n<\/code>)\u3002<\/li>\n<\/ul>\n<p class=\"font-claude-response-body break-words whitespace-normal\" dir=\"ltr\">\u4e24\u8005\u7b97\u51fa\u6765\u7684\u7cfb\u6570\u51e0\u4e4e\u4e00\u6837!\u4e5f\u5c31\u662f\u8bf4 p \u4ece 1\/2 \u964d\u5230 1\/4,\u67e5\u627e\u6027\u80fd\u51e0\u4e4e\u6ca1\u6709\u635f\u5931,\u4f46\u5185\u5b58\u5f00\u9500\u660e\u663e\u4e0b\u964d\u3002\u8fd9\u6b63\u662f Pugh \u8bba\u6587\u7684\u7ed3\u8bba:p=1\/4\uff08\u6216\u8005\u66f4\u6781\u7aef\u7684 1\/e\uff09\u5728\u65f6\u95f4\u548c\u7a7a\u95f4\u7684\u7efc\u5408\u8868\u73b0\u4e0a\u6bd4 p=1\/2 \u66f4\u5212\u7b97,p=1\/2 \u53ea\u662f&#8221;\u66f4\u5bb9\u6613\u8bb2\u6e05\u695a\u539f\u7406&#8221;\u7684\u6559\u5b66\u7248\u672c,\u4e0d\u662f\u5de5\u7a0b\u4e0a\u7684\u6700\u4f18\u9009\u62e9\u3002<\/p>\n<h3 class=\"mt-3 -mb-1 text-[1.125rem] font-bold\" dir=\"ltr\">\u4e3a\u4ec0\u4e48 Redis \u5728\u610f\u8fd9\u4e2a\u6743\u8861<\/h3>\n<p class=\"font-claude-response-body break-words whitespace-normal\" dir=\"ltr\">Redis \u662f\u5185\u5b58\u6570\u636e\u5e93,\u5185\u5b58\u672c\u6765\u5c31\u662f\u6700\u8d35\u3001\u6700\u7d27\u4fcf\u7684\u8d44\u6e90,\u80fd\u7701\u5219\u7701\u3002\u65e2\u7136 p=1\/4 \u80fd\u5728\u67e5\u627e\u901f\u5ea6\u51e0\u4e4e\u4e0d\u53d7\u5f71\u54cd\u7684\u524d\u63d0\u4e0b\u7701\u4e0b\u53ef\u89c2\u7684\u6307\u9488\u5185\u5b58,\u81ea\u7136\u662f\u66f4\u5212\u7b97\u7684\u9009\u62e9\u3002\u8fd9\u548c\u524d\u9762\u804a\u5230\u7684&#8221;\u5c0f\u5bf9\u8c61\u7528\u538b\u7f29\u7f16\u7801\u7701\u5185\u5b58&#8221;\u662f\u540c\u4e00\u79cd\u8bbe\u8ba1\u54f2\u5b66:\u6027\u80fd\u8fc7\u5f97\u53bb\u7684\u524d\u63d0\u4e0b,\u4f18\u5148\u7701\u5185\u5b58\u3002<\/p>\n<p class=\"font-claude-response-body break-words whitespace-normal\" dir=\"ltr\">\u5bf9\u5e94\u7684,Redis \u91cc <code class=\"bg-text-200\/5 border border-0.5 border-border-300 text-danger-000 whitespace-pre-wrap rounded-[0.4rem] px-1 py-px text-[0.9rem]\">ZSKIPLIST_MAXLEVEL<\/code> \u5b9a\u4e3a 32,\u662f\u56e0\u4e3a p=1\/4 \u65f6,\u5c42\u6570\u589e\u957f\u5f97\u6bd4 p=1\/2 \u6162\uff08\u8d8a\u5f80\u4e0a\u6982\u7387\u8870\u51cf\u8d8a\u5feb: 1\/4, 1\/16, 1\/64\u2026),32 \u5c42\u7406\u8bba\u4e0a\u8db3\u4ee5\u652f\u6491\u8fdc\u8d85\u5b9e\u9645\u4f7f\u7528\u89c4\u6a21\u7684\u6570\u636e\u91cf\uff08\u5b98\u65b9\u6ce8\u91ca\u91cc\u7ed9\u51fa\u7684\u4f30\u8ba1\u662f\u80fd\u652f\u6491\u5230 2^64 \u7ea7\u522b\u7684\u5143\u7d20\u6570,\u5b9e\u9645\u4e0d\u53ef\u80fd\u7528\u5230\u8fd9\u4e48\u9ad8)\u3002<\/p>\n<h3 class=\"mt-3 -mb-1 text-[1.125rem] font-bold\" dir=\"ltr\">\u4e00\u53e5\u8bdd\u603b\u7ed3<\/h3>\n<p class=\"font-claude-response-body break-words whitespace-normal\" dir=\"ltr\">p \u8d8a\u5c0f,\u8282\u70b9\u664b\u5347\u5230\u9ad8\u5c42\u7684\u6982\u7387\u8d8a\u4f4e,\u5e73\u5747\u6307\u9488\u6570\u8d8a\u5c11\u3001\u8d8a\u7701\u5185\u5b58,\u4f46\u6bcf\u5c42\u80fd\u8df3\u8fc7\u7684\u8282\u70b9\u53d8\u5c11,\u641c\u7d22\u65f6\u9700\u8981\u66f4\u591a\u5c42\u95f4\u6bd4\u8f83\uff1bp=1\/2 \u662f\u6700\u76f4\u89c2\u4f46\u4e0d\u662f\u6700\u4f18\u7684\u9009\u62e9,p=1\/4 \u662f Pugh \u8bba\u6587\u548c Redis \u5b9e\u6d4b\u90fd\u9a8c\u8bc1\u8fc7\u7684&#8221;\u67e5\u627e\u6027\u80fd\u51e0\u4e4e\u4e0d\u6389\u3001\u5185\u5b58\u5f00\u9500\u660e\u663e\u66f4\u7701&#8221;\u7684\u751c\u871c\u70b9,\u6240\u4ee5 Redis \u9009\u4e86 1\/4\u3002<\/p>\n<\/div>\n<\/div>\n<\/div>\n<\/div>\n<\/div>\n<\/div>\n<\/div>\n<\/div>\n","protected":false},"excerpt":{"rendered":"<p>\u8fd9\u4e2a\u95ee\u9898 Redis \u4f5c\u8005 antire<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"colormag_page_container_layout":"default_layout","colormag_page_sidebar_layout":"default_layout","footnotes":""},"categories":[24],"tags":[],"class_list":["post-7656","post","type-post","status-publish","format-standard","hentry","category-value_docs"],"_links":{"self":[{"href":"https:\/\/i007.cc\/wordpress\/wp-json\/wp\/v2\/posts\/7656","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/i007.cc\/wordpress\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/i007.cc\/wordpress\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/i007.cc\/wordpress\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/i007.cc\/wordpress\/wp-json\/wp\/v2\/comments?post=7656"}],"version-history":[{"count":1,"href":"https:\/\/i007.cc\/wordpress\/wp-json\/wp\/v2\/posts\/7656\/revisions"}],"predecessor-version":[{"id":7657,"href":"https:\/\/i007.cc\/wordpress\/wp-json\/wp\/v2\/posts\/7656\/revisions\/7657"}],"wp:attachment":[{"href":"https:\/\/i007.cc\/wordpress\/wp-json\/wp\/v2\/media?parent=7656"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/i007.cc\/wordpress\/wp-json\/wp\/v2\/categories?post=7656"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/i007.cc\/wordpress\/wp-json\/wp\/v2\/tags?post=7656"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}