doc: 阅读redis cluster replcia文档

This commit is contained in:
asahi
2025-09-30 15:20:09 +08:00
parent 964cd99e7a
commit 008fe45df1

View File

@@ -225,6 +225,7 @@
- [Client connections and redirection handling](#client-connections-and-redirection-handling)
- [CLUSTER SLOTS](#cluster-slots)
- [Multi-keys operations](#multi-keys-operations)
- [Scaling reads using replica nodes](#scaling-reads-using-replica-nodes)
# redis
@@ -3586,3 +3587,14 @@ MSET {user:1000}.name Angela {user:1000}.surname White
当指定hash slots的迁移完成后关于该hash slot所有的`multi-key operations`都允许被执行。
#### Scaling reads using replica nodes
通常来讲replica nodes在接收到命令时都会将其重定向给负责该hash slot的master node。但是对于readonly命令client可以使用replicas来对读操作进行扩展。
`READONLY`会告知redis cluster replica node如下信息当前client`接收读取可能过时的数据`,并且`不会发送写请求`
当connection处于readonly模式时cluster只会在`the operation involves keys not served by the replica's master node`才会向client发送重定向。造成该问题的原因可能如下
- the client sent a command about hash slots never served by the master of this replica
- the cluster was reconfigured and the replica is no longer able to serve commands for a given hash slot
当发生该场景时replica会向client发送重定向而client则应该更新其`hash slot map`