diff --git a/generic_commands.go b/generic_commands.go index dc6c3fe014..b70e8def16 100644 --- a/generic_commands.go +++ b/generic_commands.go @@ -3,6 +3,8 @@ package redis import ( "context" "time" + + "github.com/redis/go-redis/v9/internal/hashtag" ) type GenericCmdable interface { @@ -363,6 +365,9 @@ func (c cmdable) Scan(ctx context.Context, cursor uint64, match string, count in args = append(args, "count", count) } cmd := NewScanCmd(ctx, c, args...) + if hashtag.Present(match) { + cmd.SetFirstKeyPos(3) + } _ = c(ctx, cmd) return cmd } diff --git a/go.mod b/go.mod index c1d9037acc..3ab465b54c 100644 --- a/go.mod +++ b/go.mod @@ -1,4 +1,4 @@ -module github.com/redis/go-redis/v9 +module github.com/ns-ofang/go-redis go 1.18 @@ -8,8 +8,3 @@ require ( github.com/cespare/xxhash/v2 v2.2.0 github.com/dgryski/go-rendezvous v0.0.0-20200823014737-9f7001d12a5f ) - -retract ( - v9.5.4 // This version was accidentally released. Please use version 9.6.0 instead. - v9.5.3 // This version was accidentally released. Please use version 9.6.0 instead. -) diff --git a/internal/hashtag/hashtag.go b/internal/hashtag/hashtag.go index f13ee816d6..ea56fd6c7c 100644 --- a/internal/hashtag/hashtag.go +++ b/internal/hashtag/hashtag.go @@ -56,6 +56,18 @@ func Key(key string) string { return key } +func Present(key string) bool { + if key == "" { + return false + } + if s := strings.IndexByte(key, '{'); s > -1 { + if e := strings.IndexByte(key[s+1:], '}'); e > 0 { + return true + } + } + return false +} + func RandomSlot() int { return rand.Intn(slotNumber) }