From 87949598352759b0434ea57e087f4876fb5cfede Mon Sep 17 00:00:00 2001 From: keepchen Date: Tue, 16 Jul 2024 11:09:04 +0800 Subject: [PATCH] =?UTF-8?q?=E6=96=B0=E5=A2=9E=E8=AE=BE=E7=BD=AE=E8=BF=9E?= =?UTF-8?q?=E6=8E=A5=E5=AE=9E=E4=BE=8B=E8=AF=AD=E6=B3=95=E7=B3=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- README.md | 6 ++++++ redislock.go | 14 ++++++++++++++ 2 files changed, 20 insertions(+) diff --git a/README.md b/README.md index d5b500d..bf3f6b4 100644 --- a/README.md +++ b/README.md @@ -27,6 +27,12 @@ corgi.SetRedisProviderCluster(...) //or corgi.SetRedisProviderFailOver(...) + +//or +corgi.SetRedisProviderClient(...) + +//or +corgi.SetRedisProviderClusterClient(...) ``` #### Lock ```go diff --git a/redislock.go b/redislock.go index 4598936..784497b 100644 --- a/redislock.go +++ b/redislock.go @@ -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)