diff --git a/README.md b/README.md index d6cd9d4..71a3cf3 100644 --- a/README.md +++ b/README.md @@ -25,13 +25,15 @@ DelayQueue requires a Go version with modules support. Run following command lin go get github.com/hdt3213/delayqueue ``` +> if you are using github.com/go-redis/redis/v8 please use `go get github.com/hdt3213/delayqueue@v8` + ## Get Started ```go package main import ( - "github.com/go-redis/redis/v8" + "github.com/redis/go-redis/v9" "github.com/hdt3213/delayqueue" "strconv" "time" diff --git a/README_CN.md b/README_CN.md index 9902e36..7bff1c5 100644 --- a/README_CN.md +++ b/README_CN.md @@ -21,13 +21,15 @@ DelayQueue 的主要优势: go get github.com/hdt3213/delayqueue ``` +> 如果您仍在使用 `github.com/go-redis/redis/v8` 请安装 `go get github.com/hdt3213/delayqueue@v8` + # 开始使用 ```go package main import ( - "github.com/go-redis/redis/v8" + "github.com/redis/go-redis/v9" "github.com/hdt3213/delayqueue" "strconv" "time" diff --git a/delayqueue.go b/delayqueue.go index 65d299b..e763026 100644 --- a/delayqueue.go +++ b/delayqueue.go @@ -3,8 +3,8 @@ package delayqueue import ( "context" "fmt" - "github.com/go-redis/redis/v8" "github.com/google/uuid" + "github.com/redis/go-redis/v9" "log" "sync" "time" @@ -179,7 +179,7 @@ func (q *DelayQueue) SendScheduleMsg(payload string, t time.Time, opts ...interf return fmt.Errorf("store retry count failed: %v", err) } // put to pending - err = q.redisCli.ZAdd(ctx, q.pendingKey, &redis.Z{Score: float64(t.Unix()), Member: idStr}).Err() + err = q.redisCli.ZAdd(ctx, q.pendingKey, redis.Z{Score: float64(t.Unix()), Member: idStr}).Err() if err != nil { return fmt.Errorf("push to pending failed: %v", err) } @@ -340,7 +340,7 @@ func (q *DelayQueue) ack(idStr string) error { func (q *DelayQueue) nack(idStr string) error { ctx := context.Background() // update retry time as now, unack2Retry will move it to retry immediately - err := q.redisCli.ZAdd(ctx, q.unAckKey, &redis.Z{ + err := q.redisCli.ZAdd(ctx, q.unAckKey, redis.Z{ Member: idStr, Score: float64(time.Now().Unix()), }).Err() diff --git a/delayqueue_test.go b/delayqueue_test.go index 7f9ea0f..9c29839 100644 --- a/delayqueue_test.go +++ b/delayqueue_test.go @@ -2,7 +2,7 @@ package delayqueue import ( "context" - "github.com/go-redis/redis/v8" + "github.com/redis/go-redis/v9" "log" "os" "strconv" diff --git a/exmaple/main.go b/exmaple/main.go index b41f122..88a19ff 100644 --- a/exmaple/main.go +++ b/exmaple/main.go @@ -1,8 +1,8 @@ package main import ( - "github.com/go-redis/redis/v8" "github.com/hdt3213/delayqueue" + "github.com/redis/go-redis/v9" "strconv" "time" ) diff --git a/go.mod b/go.mod index cd2d310..df3c66b 100644 --- a/go.mod +++ b/go.mod @@ -3,6 +3,6 @@ module github.com/hdt3213/delayqueue go 1.16 require ( - github.com/go-redis/redis/v8 v8.11.4 github.com/google/uuid v1.3.0 + github.com/redis/go-redis/v9 v9.0.5 // indirect ) diff --git a/go.sum b/go.sum index f3e2acb..d107bb3 100644 --- a/go.sum +++ b/go.sum @@ -1,5 +1,9 @@ +github.com/bsm/ginkgo/v2 v2.7.0/go.mod h1:AiKlXPm7ItEHNc/2+OkrNG4E0ITzojb9/xWzvQ9XZ9w= +github.com/bsm/gomega v1.26.0/go.mod h1:JyEr/xRbxbtgWNi8tIEVPUYZ5Dzef52k01W3YH0H+O0= github.com/cespare/xxhash/v2 v2.1.2 h1:YRXhKfTDauu4ajMg1TPgFO5jnlC2HCbmLXMcTG5cbYE= github.com/cespare/xxhash/v2 v2.1.2/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs= +github.com/cespare/xxhash/v2 v2.2.0 h1:DC2CZ1Ep5Y4k3ZQ899DldepgrayRUGE6BBZ/cd9Cj44= +github.com/cespare/xxhash/v2 v2.2.0/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs= github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/dgryski/go-rendezvous v0.0.0-20200823014737-9f7001d12a5f h1:lO4WD4F/rVNCu3HqELle0jiPLLBs70cWOduZpkS1E78= @@ -39,6 +43,8 @@ github.com/onsi/gomega v1.10.1/go.mod h1:iN09h71vgCQne3DLsj+A5owkum+a2tYe+TOCB1y github.com/onsi/gomega v1.16.0 h1:6gjqkI8iiRHMvdccRJM8rVKjCWk6ZIm6FTm3ddIe4/c= github.com/onsi/gomega v1.16.0/go.mod h1:HnhC7FXeEQY45zxNK3PPoIUhzk/80Xly9PcubAlGdZY= github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= +github.com/redis/go-redis/v9 v9.0.5 h1:CuQcn5HIEeK7BgElubPP8CGtE0KakrnbBSTLjathl5o= +github.com/redis/go-redis/v9 v9.0.5/go.mod h1:WqMKv5vnQbRuZstUwxQI195wHy+t4PuXDOjzMvcuQHk= github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= github.com/stretchr/testify v1.5.1/go.mod h1:5W2xD1RspED5o8YsWQXVCued0rvSQ+mT+I5cxcmMvtA= github.com/yuin/goldmark v1.2.1/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74=