1
0
mirror of https://github.com/redis/go-redis.git synced 2025-07-31 05:04:23 +03:00

Don't enable ReadOnly in custom cluster mode

This commit is contained in:
Vladimir Mihailenco
2018-09-20 12:49:43 +03:00
parent 40dbb03d62
commit 69445c6e87
2 changed files with 56 additions and 2 deletions

View File

@ -82,7 +82,7 @@ func (opt *ClusterOptions) init() {
opt.MaxRedirects = 8
}
if opt.RouteByLatency || opt.RouteRandomly {
if (opt.RouteByLatency || opt.RouteRandomly) && opt.ClusterSlots == nil {
opt.ReadOnly = true
}
@ -831,7 +831,7 @@ func (c *ClusterClient) cmdSlotAndNode(cmd Cmder) (int, *clusterNode, error) {
cmdInfo := c.cmdInfo(cmd.Name())
slot := cmdSlot(cmd, cmdFirstKeyPos(cmd, cmdInfo))
if cmdInfo != nil && cmdInfo.ReadOnly && c.opt.ReadOnly {
if c.opt.ReadOnly && cmdInfo != nil && cmdInfo.ReadOnly {
if c.opt.RouteByLatency {
node, err := state.slotClosestNode(slot)
return slot, node, err