1
0
mirror of https://github.com/redis/go-redis.git synced 2025-07-29 17:41:15 +03:00

fix(cmdSlot): Add shortlist of keyless cmds

This commit is contained in:
Nedyalko Dyakov
2025-06-19 12:26:06 +03:00
parent 0f66cd002d
commit 185ec01461

View File

@ -75,12 +75,17 @@ func writeCmd(wr *proto.Writer, cmd Cmder) error {
return wr.WriteArgs(cmd.Args()) return wr.WriteArgs(cmd.Args())
} }
// cmdFirstKeyPos returns the position of the first key in the command's arguments.
// If the command does not have a key, it returns 0.
// TODO: Use the data in CommandInfo to determine the first key position.
func cmdFirstKeyPos(cmd Cmder) int { func cmdFirstKeyPos(cmd Cmder) int {
if pos := cmd.firstKeyPos(); pos != 0 { if pos := cmd.firstKeyPos(); pos != 0 {
return int(pos) return int(pos)
} }
switch cmd.Name() { switch cmd.Name() {
case "echo", "ping", "command":
return 0
case "eval", "evalsha", "eval_ro", "evalsha_ro": case "eval", "evalsha", "eval_ro", "evalsha_ro":
if cmd.stringArg(2) != "0" { if cmd.stringArg(2) != "0" {
return 3 return 3