Skip to content

Commit

Permalink
fix: askingMultiCache should retry {Cmd} with ASKING
Browse files Browse the repository at this point in the history
  • Loading branch information
wuyuxiang committed Dec 16, 2024
1 parent 891d632 commit 5c2c274
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions cluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -828,15 +828,21 @@ func askingMulti(cc conn, ctx context.Context, multi []Completed) *redisresults
}

func askingMultiCache(cc conn, ctx context.Context, multi []CacheableTTL) *redisresults {
commands := make([]Completed, 0, len(multi)*6)
commands := make([]Completed, 0, len(multi)*7)
for _, cmd := range multi {
ck, _ := cmds.CacheKey(cmd.Cmd)
commands = append(commands, cmds.OptInCmd, cmds.MultiCmd, cmds.AskingCmd, cmds.NewCompleted([]string{"PTTL", ck}), Completed(cmd.Cmd), cmds.ExecCmd)
commands = append(commands, cmds.OptInCmd, cmds.MultiCmd, cmds.AskingCmd, cmds.NewCompleted([]string{"PTTL", ck}), cmds.AskingCmd, Completed(cmd.Cmd), cmds.ExecCmd)
}
results := resultsp.Get(0, len(multi))
resps := cc.DoMulti(ctx, commands...)
for i := 5; i < len(resps.s); i += 6 {
for i := 6; i < len(resps.s); i += 7 {
if arr, err := resps.s[i].ToArray(); err != nil {
for _, j := range []int{i - 3, i - 1} { // check if PTTL or {Cmd} failed
if preErr := resps.s[j].Error(); preErr != nil {
err = preErr
break
}
}
results.s = append(results.s, newErrResult(err))
} else {
results.s = append(results.s, newResult(arr[len(arr)-1], nil))
Expand Down

0 comments on commit 5c2c274

Please sign in to comment.