Skip to content

Commit 51db7cb

Browse files
committed
test patch cluster support for scan operation
1 parent 1ed936e commit 51db7cb

File tree

2 files changed

+17
-0
lines changed

2 files changed

+17
-0
lines changed

generic_commands.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@ package redis
33
import (
44
"context"
55
"time"
6+
7+
"github.com/redis/go-redis/v9/internal/hashtag"
68
)
79

810
type GenericCmdable interface {
@@ -363,6 +365,9 @@ func (c cmdable) Scan(ctx context.Context, cursor uint64, match string, count in
363365
args = append(args, "count", count)
364366
}
365367
cmd := NewScanCmd(ctx, c, args...)
368+
if hashtag.Present(match) {
369+
cmd.SetFirstKeyPos(3)
370+
}
366371
_ = c(ctx, cmd)
367372
return cmd
368373
}

internal/hashtag/hashtag.go

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,18 @@ func Key(key string) string {
5656
return key
5757
}
5858

59+
func Present(key string) bool {
60+
if key == "" {
61+
return false
62+
}
63+
if s := strings.IndexByte(key, '{'); s > -1 {
64+
if e := strings.IndexByte(key[s+1:], '}'); e > 0 {
65+
return true
66+
}
67+
}
68+
return false
69+
}
70+
5971
func RandomSlot() int {
6072
return rand.Intn(slotNumber)
6173
}

0 commit comments

Comments
 (0)