support rename in cluster

This commit is contained in:
finley
2025-03-23 21:34:54 +08:00
parent 23b70325f9
commit ef4e09972c
5 changed files with 141 additions and 23 deletions

View File

@@ -123,7 +123,7 @@ func execMGet(cluster *core.Cluster, c redis.Connection, cmdLine CmdLine) redis.
for node, ret := range nodeResults {
nodeCmdLine := cmdLineMap[node]
result := ret.(*protocol.MultiBulkReply)
if len(result.Args) != len(nodeCmdLine) - 1 {
if len(result.Args) != len(nodeCmdLine)-1 {
return protocol.MakeErrReply("wrong response from node " + node)
}
for i := 1; i < len(nodeCmdLine); i++ {
@@ -143,12 +143,12 @@ func execMGet(cluster *core.Cluster, c redis.Connection, cmdLine CmdLine) redis.
const someKeysExistsErr = "Some Keys Exists"
func init() {
core.RegisterPreCheck("msetnx", msetNxPrecheck)
core.RegisterPrepareFunc("msetnx", msetNxPrecheck)
}
func msetNxPrecheck(cluster *core.Cluster, c redis.Connection, cmdLine CmdLine) redis.Reply {
var keys []string
for i := 1; i < len(cmdLine); i+=2 {
for i := 1; i < len(cmdLine); i += 2 {
keys = append(keys, string(cmdLine[i]))
}
exists := cluster.LocalExists(keys)
@@ -202,4 +202,4 @@ func execMSetNx(cluster *core.Cluster, c redis.Connection, cmdLine CmdLine) redi
return err
}
return protocol.MakeIntReply(1)
}
}