修改redis的传参,接收三种方式redis
This commit is contained in:
@@ -1,11 +1,8 @@
|
||||
module github.com/yuninks/lockx
|
||||
|
||||
go 1.19
|
||||
go 1.20
|
||||
|
||||
require (
|
||||
code.yun.ink/open/timer v1.0.1
|
||||
github.com/go-redis/redis/v8 v8.11.5
|
||||
)
|
||||
require github.com/go-redis/redis/v8 v8.11.5
|
||||
|
||||
require (
|
||||
github.com/cespare/xxhash/v2 v2.1.2 // indirect
|
||||
|
||||
@@ -1,5 +1,3 @@
|
||||
code.yun.ink/open/timer v1.0.1 h1:ZWecU5K0rFB15p8DZubozTEwo1vrO4mUCRwEoD1tbEQ=
|
||||
code.yun.ink/open/timer v1.0.1/go.mod h1:i6+mEL5eUab+9ZDtxt9S5fMiJkwVLBRsNmfLj2qzN30=
|
||||
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/dgryski/go-rendezvous v0.0.0-20200823014737-9f7001d12a5f h1:lO4WD4F/rVNCu3HqELle0jiPLLBs70cWOduZpkS1E78=
|
||||
|
||||
@@ -11,14 +11,14 @@ import (
|
||||
|
||||
// 全局锁
|
||||
type globalLock struct {
|
||||
redis *redis.Client
|
||||
redis redis.UniversalClient
|
||||
ctx context.Context
|
||||
cancel context.CancelFunc
|
||||
uniqueKey string
|
||||
value string
|
||||
}
|
||||
|
||||
func NewGlobalLock(ctx context.Context, red *redis.Client, uniqueKey string) *globalLock {
|
||||
func NewGlobalLock(ctx context.Context, red redis.UniversalClient, uniqueKey string) *globalLock {
|
||||
ctx, cancel := context.WithTimeout(ctx, opt.lockTimeout)
|
||||
return &globalLock{
|
||||
redis: red,
|
||||
|
||||
+1
-1
@@ -5,7 +5,7 @@ import (
|
||||
"fmt"
|
||||
"testing"
|
||||
|
||||
"code.yun.ink/open/timer/lockx"
|
||||
"github.com/yuninks/lockx"
|
||||
"github.com/go-redis/redis/v8"
|
||||
)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user