diff --git a/.github/workflows/test.yaml b/.github/workflows/test.yaml index 8ef5f3e..7f1ef7a 100644 --- a/.github/workflows/test.yaml +++ b/.github/workflows/test.yaml @@ -12,7 +12,7 @@ jobs: ETCD_ADVERTISE_CLIENT_URLS: http://0.0.0.0:2379 strategy: matrix: - go-version: [1.19.x] + go-version: [1.21.x, 1.22.x] os: [ubuntu-latest] runs-on: ${{ matrix.os }} steps: diff --git a/xmsgbus/impl/redis/storage.go b/xmsgbus/impl/redis/storage.go index 53c394a..37f7f6b 100644 --- a/xmsgbus/impl/redis/storage.go +++ b/xmsgbus/impl/redis/storage.go @@ -2,6 +2,7 @@ package redis import ( "context" + "strings" "time" "github.com/ccheers/xpkg/xmsgbus" @@ -21,7 +22,10 @@ func (x *SharedStorage) SetEx(ctx context.Context, key string, value interface{} } func (x *SharedStorage) Keys(ctx context.Context, prefix string) ([]string, error) { - return x.client.Keys(ctx, prefix+"*").Result() + if !strings.HasSuffix(prefix, "*") { + prefix += "*" + } + return x.client.Keys(ctx, prefix).Result() } func (x *SharedStorage) Del(ctx context.Context, key string) error { diff --git a/xmsgbus/topicmanager.go b/xmsgbus/topicmanager.go index 1b054f9..f029c6e 100644 --- a/xmsgbus/topicmanager.go +++ b/xmsgbus/topicmanager.go @@ -135,7 +135,7 @@ func (x *TopicManager) check(ctx context.Context, topic string) { } for _, channel := range channels { - results, err := x.storage.Keys(ctx, x.subKeyPrefix(topic, channel)+"*") + results, err := x.storage.Keys(ctx, x.subKeyPrefix(topic, channel)) if err != nil { _ = xlogger.DefaultLogger.Log(xlogger.LevelError, "err", err,