Skip to content

Commit e2149b0

Browse files
authored
Use correct slot for COUNTKEYSINSLOT command (#3327)
1 parent 7b9bd6c commit e2149b0

File tree

2 files changed

+25
-1
lines changed

2 files changed

+25
-1
lines changed

internal_test.go

+24
Original file line numberDiff line numberDiff line change
@@ -352,3 +352,27 @@ var _ = Describe("withConn", func() {
352352
Expect(client.connPool.Len()).To(Equal(1))
353353
})
354354
})
355+
356+
var _ = Describe("ClusterClient", func() {
357+
var client *ClusterClient
358+
359+
BeforeEach(func() {
360+
client = &ClusterClient{}
361+
})
362+
363+
Describe("cmdSlot", func() {
364+
It("select slot from args for GETKEYSINSLOT command", func() {
365+
cmd := NewStringSliceCmd(ctx, "cluster", "getkeysinslot", 100, 200)
366+
367+
slot := client.cmdSlot(context.Background(), cmd)
368+
Expect(slot).To(Equal(100))
369+
})
370+
371+
It("select slot from args for COUNTKEYSINSLOT command", func() {
372+
cmd := NewStringSliceCmd(ctx, "cluster", "countkeysinslot", 100)
373+
374+
slot := client.cmdSlot(context.Background(), cmd)
375+
Expect(slot).To(Equal(100))
376+
})
377+
})
378+
})

osscluster.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -1856,7 +1856,7 @@ func (c *ClusterClient) cmdInfo(ctx context.Context, name string) *CommandInfo {
18561856

18571857
func (c *ClusterClient) cmdSlot(ctx context.Context, cmd Cmder) int {
18581858
args := cmd.Args()
1859-
if args[0] == "cluster" && args[1] == "getkeysinslot" {
1859+
if args[0] == "cluster" && (args[1] == "getkeysinslot" || args[1] == "countkeysinslot") {
18601860
return args[2].(int)
18611861
}
18621862

0 commit comments

Comments
 (0)