Skip to content

Commit

Permalink
新增设置连接实例语法糖
Browse files Browse the repository at this point in the history
  • Loading branch information
keepchen committed Jul 16, 2024
1 parent 620c3c3 commit 8794959
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 0 deletions.
6 changes: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,12 @@ corgi.SetRedisProviderCluster(...)

//or
corgi.SetRedisProviderFailOver(...)

//or
corgi.SetRedisProviderClient(...)

//or
corgi.SetRedisProviderClusterClient(...)
```
#### Lock
```go
Expand Down
14 changes: 14 additions & 0 deletions redislock.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,20 @@ func SetRedisProviderFailOver(opt *redisLib.FailoverOptions) {
})
}

// SetRedisProviderClient 设置redis连接实例(单实例)
func SetRedisProviderClient(client *redisLib.Client) {
doOnce.Do(func() {
lockDriver.client = client
})
}

// SetRedisProviderClusterClient 设置redis连接实例(cluster集群)
func SetRedisProviderClusterClient(client *redisLib.ClusterClient) {
doOnce.Do(func() {
lockDriver.clusterClient = client
})
}

func initClient(opt *redisLib.Options) {
rdb := redisLib.NewClient(opt)

Expand Down

0 comments on commit 8794959

Please sign in to comment.