Skip to content

Commit 9d109c3

Browse files
authored
Merge branch 'master' into ISSUE-3402
2 parents 7529b11 + fa475cb commit 9d109c3

File tree

12 files changed

+684
-80
lines changed

12 files changed

+684
-80
lines changed

.github/workflows/spellcheck.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ jobs:
88
- name: Checkout
99
uses: actions/checkout@v4
1010
- name: Check Spelling
11-
uses: rojopolis/spellcheck-github-actions@0.49.0
11+
uses: rojopolis/spellcheck-github-actions@0.51.0
1212
with:
1313
config_path: .github/spellcheck-settings.yml
1414
task_name: Markdown

command.go

Lines changed: 60 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,55 @@ import (
1717
"github.com/redis/go-redis/v9/internal/util"
1818
)
1919

20+
// keylessCommands contains Redis commands that have empty key specifications (9th slot empty)
21+
// Only includes core Redis commands, excludes FT.*, ts.*, timeseries.*, search.* and subcommands
22+
var keylessCommands = map[string]struct{}{
23+
"acl": {},
24+
"asking": {},
25+
"auth": {},
26+
"bgrewriteaof": {},
27+
"bgsave": {},
28+
"client": {},
29+
"cluster": {},
30+
"config": {},
31+
"debug": {},
32+
"discard": {},
33+
"echo": {},
34+
"exec": {},
35+
"failover": {},
36+
"function": {},
37+
"hello": {},
38+
"latency": {},
39+
"lolwut": {},
40+
"module": {},
41+
"monitor": {},
42+
"multi": {},
43+
"pfselftest": {},
44+
"ping": {},
45+
"psubscribe": {},
46+
"psync": {},
47+
"publish": {},
48+
"pubsub": {},
49+
"punsubscribe": {},
50+
"quit": {},
51+
"readonly": {},
52+
"readwrite": {},
53+
"replconf": {},
54+
"replicaof": {},
55+
"role": {},
56+
"save": {},
57+
"script": {},
58+
"select": {},
59+
"shutdown": {},
60+
"slaveof": {},
61+
"slowlog": {},
62+
"subscribe": {},
63+
"swapdb": {},
64+
"sync": {},
65+
"unsubscribe": {},
66+
"unwatch": {},
67+
}
68+
2069
type Cmder interface {
2170
// command name.
2271
// e.g. "set k v ex 10" -> "set", "cluster info" -> "cluster".
@@ -75,12 +124,22 @@ func writeCmd(wr *proto.Writer, cmd Cmder) error {
75124
return wr.WriteArgs(cmd.Args())
76125
}
77126

127+
// cmdFirstKeyPos returns the position of the first key in the command's arguments.
128+
// If the command does not have a key, it returns 0.
129+
// TODO: Use the data in CommandInfo to determine the first key position.
78130
func cmdFirstKeyPos(cmd Cmder) int {
79131
if pos := cmd.firstKeyPos(); pos != 0 {
80132
return int(pos)
81133
}
82134

83-
switch cmd.Name() {
135+
name := cmd.Name()
136+
137+
// first check if the command is keyless
138+
if _, ok := keylessCommands[name]; ok {
139+
return 0
140+
}
141+
142+
switch name {
84143
case "eval", "evalsha", "eval_ro", "evalsha_ro":
85144
if cmd.stringArg(2) != "0" {
86145
return 3

0 commit comments

Comments
 (0)