Update Redis.md

补充对象编码,以及 Redis Cluster 的哈希槽、重定向、哈希标签和故障转移,并配图。
This commit is contained in:
CyC2018
2026-10-26 02:34:35 +08:00
parent e2c554d7de
commit 91676af01c
3 changed files with 104 additions and 0 deletions
+69
View File
@@ -0,0 +1,69 @@
<svg xmlns="http://www.w3.org/2000/svg" width="720" height="340" viewBox="0 0 720 340">
<style>
text { font-family: "PingFang SC", "Microsoft YaHei", Helvetica, Arial, sans-serif; fill: #666; font-size: 12px; }
.title { font-weight: bold; font-size: 15px; fill: #777; text-anchor: middle; }
.b { font-weight: bold; }
.c { text-anchor: middle; }
.e { text-anchor: end; }
.note { fill: #C0605A; }
.ok { fill: #6A9F68; }
.sub { font-size: 11px; fill: #888; }
.mono { font-family: Menlo, Consolas, monospace; }
.arrow { stroke: #666; stroke-width: 1.3; fill: none; marker-end: url(#a); }
.red { stroke: #C0605A; marker-end: url(#r); }
.green { stroke: #6A9F68; marker-end: url(#g); }
.dash { stroke-dasharray: 5 4; }
.line { stroke: #666; stroke-width: 1.3; fill: none; }
.frame { fill: none; stroke: #999; stroke-width: 1; stroke-dasharray: 4 3; }
.shadow { fill: #DADADA; }
</style>
<defs>
<marker id="a" viewBox="0 0 10 10" refX="9" refY="5" markerWidth="7" markerHeight="7" orient="auto-start-reverse">
<path d="M1,1 L9,5 L1,9" fill="none" stroke="#666" stroke-width="1.6"/>
</marker>
<marker id="r" viewBox="0 0 10 10" refX="9" refY="5" markerWidth="7" markerHeight="7" orient="auto-start-reverse">
<path d="M1,1 L9,5 L1,9" fill="none" stroke="#C0605A" stroke-width="1.6"/>
</marker>
<marker id="g" viewBox="0 0 10 10" refX="9" refY="5" markerWidth="7" markerHeight="7" orient="auto-start-reverse">
<path d="M1,1 L9,5 L1,9" fill="none" stroke="#6A9F68" stroke-width="1.6"/>
</marker>
</defs>
<rect width="100%" height="100%" fill="#FFFFFF"/>
<text x="360" y="28" class="title">Redis Cluster:3 主 3 从</text>
<rect x="22" y="54" width="210" height="54" rx="6" class="shadow"/>
<rect x="20" y="52" width="210" height="54" rx="6" fill="#DDD7F6"/>
<text x="125" y="74" class="c b mono">user:1001</text>
<text x="125" y="94" class="c sub mono">CRC16(key) % 16384 = 5712</text>
<rect x="252" y="152" width="140" height="52" rx="6" class="shadow"/>
<rect x="250" y="150" width="140" height="52" rx="6" fill="#B1DDF0"/>
<text x="320" y="174" class="b c">主节点 7001</text>
<text x="320" y="189" class="sub c">槽 0~5460</text>
<rect x="262" y="252" width="120" height="36" rx="6" class="shadow"/>
<rect x="260" y="250" width="120" height="36" rx="6" fill="#E6E6E6"/>
<text x="320" y="272.5" class="b c">从节点</text>
<line x1="320" y1="205" x2="320" y2="246" class="arrow dash"/>
<rect x="402" y="152" width="140" height="52" rx="6" class="shadow"/>
<rect x="400" y="150" width="140" height="52" rx="6" fill="#B1DDF0"/>
<text x="470" y="174" class="b c">主节点 7002</text>
<text x="470" y="189" class="sub c">槽 5461~10922</text>
<rect x="412" y="252" width="120" height="36" rx="6" class="shadow"/>
<rect x="410" y="250" width="120" height="36" rx="6" fill="#E6E6E6"/>
<text x="470" y="272.5" class="b c">从节点</text>
<line x1="470" y1="205" x2="470" y2="246" class="arrow dash"/>
<rect x="552" y="152" width="140" height="52" rx="6" class="shadow"/>
<rect x="550" y="150" width="140" height="52" rx="6" fill="#B1DDF0"/>
<text x="620" y="174" class="b c">主节点 7003</text>
<text x="620" y="189" class="sub c">槽 10923~16383</text>
<rect x="562" y="252" width="120" height="36" rx="6" class="shadow"/>
<rect x="560" y="250" width="120" height="36" rx="6" fill="#E6E6E6"/>
<text x="620" y="272.5" class="b c">从节点</text>
<line x1="620" y1="205" x2="620" y2="246" class="arrow dash"/>
<text x="325" y="236" class="sub">异步复制</text>
<path d="M232,92 C330,96 440,110 470,146" class="arrow"/>
<text x="380" y="104" class="c sub">槽 5712 在 7002</text>
<text x="20" y="128" class="sub note">如果发给 7001:MOVED 5712 127.0.0.1:7002</text>
<path d="M100,136 C100,166 200,176 246,176" class="arrow red dash"/>
<text x="20" y="312" class="sub">{user:1001}:cart 和 {user:1001}:orders 只按 {} 中的部分计算,都在槽 5712,可以在同一条命令或 Lua 脚本中使用</text>
<text x="20" y="330" class="sub">主节点宕机后,从节点被选为新的主节点;本机 cluster-node-timeout 为 5 秒时,这部分槽约 9 秒无法写入</text>
</svg>

After

Width:  |  Height:  |  Size: 4.2 KiB