From 51177dd5257306620d4bd20b834dfafc4487ec51 Mon Sep 17 00:00:00 2001 From: wh_zcy Date: Fri, 9 Sep 2022 18:28:12 +0800 Subject: [PATCH] =?UTF-8?q?=E5=90=AF=E5=8A=A8=E6=97=B6=E6=B8=85=E7=A9=BAre?= =?UTF-8?q?dis?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lego/sys/redis/cluster/core.go | 4 ++++ lego/sys/redis/core.go | 6 ++++++ lego/sys/redis/redis.go | 4 ++++ lego/sys/redis/single/core.go | 4 ++++ sys/db/core.go | 7 ++++++- 5 files changed, 24 insertions(+), 1 deletion(-) diff --git a/lego/sys/redis/cluster/core.go b/lego/sys/redis/cluster/core.go index e27d64e36..596ffbe03 100644 --- a/lego/sys/redis/cluster/core.go +++ b/lego/sys/redis/cluster/core.go @@ -114,3 +114,7 @@ func (this *Redis) ScriptExists(ctx context.Context, hashes ...string) *redis.Bo // func (this *Redis) ScriptLoad(ctx context.Context, script string) *redis.StringCmd { // return this.client.ScriptLoad(ctx, script) // } + +func (this *Redis) FlushAll(ctx context.Context) *redis.StatusCmd { + return this.client.FlushAll(ctx) +} diff --git a/lego/sys/redis/core.go b/lego/sys/redis/core.go index bd8ff4bf1..56afed7d4 100644 --- a/lego/sys/redis/core.go +++ b/lego/sys/redis/core.go @@ -124,6 +124,8 @@ type ( EvalSha(ctx context.Context, sha1 string, keys []string, args ...interface{}) *redis.Cmd ScriptExists(ctx context.Context, hashes ...string) *redis.BoolSliceCmd // ScriptLoad(ctx context.Context, script string) *redis.StringCmd + // + FlushAll(ctx context.Context) *redis.StatusCmd } ISys interface { @@ -489,3 +491,7 @@ func EvalSha(ctx context.Context, sha1 string, keys []string, args ...interface{ func ScriptExists(ctx context.Context, hashes ...string) *redis.BoolSliceCmd { return defsys.ScriptExists(ctx, hashes...) } + +func FlushAll(ctx context.Context) *redis.StatusCmd { + return defsys.FlushAll(ctx) +} diff --git a/lego/sys/redis/redis.go b/lego/sys/redis/redis.go index d2d33e048..b7dbf9bb2 100644 --- a/lego/sys/redis/redis.go +++ b/lego/sys/redis/redis.go @@ -379,6 +379,10 @@ func (this *Redis) ScriptExists(ctx context.Context, hashes ...string) *redis.Bo return this.client.ScriptExists(ctx, hashes...) } +func (this *Redis) FlushAll(ctx context.Context) *redis.StatusCmd { + return this.client.FlushAll(ctx) +} + //Codec--------------------------------------------------------------------------------------------------------------------------------------- func (this *Redis) Marshal(v interface{}) ([]byte, error) { if this.options.Codec != nil { diff --git a/lego/sys/redis/single/core.go b/lego/sys/redis/single/core.go index a07e87ac9..b96d4448f 100644 --- a/lego/sys/redis/single/core.go +++ b/lego/sys/redis/single/core.go @@ -111,3 +111,7 @@ func (this *Redis) ScriptExists(ctx context.Context, hashes ...string) *redis.Bo // func (this *Redis) ScriptLoad(ctx context.Context, script string) *redis.StringCmd { // return this.client.ScriptLoad(ctx, script) // } + +func (this *Redis) FlushAll(ctx context.Context) *redis.StatusCmd { + return this.client.FlushAll(ctx) +} diff --git a/sys/db/core.go b/sys/db/core.go index 9650f815b..f56be3eab 100644 --- a/sys/db/core.go +++ b/sys/db/core.go @@ -1,6 +1,9 @@ package db -import "time" +import ( + "context" + "time" +) type ( ISys interface { @@ -31,6 +34,8 @@ func OnInit(config map[string]interface{}, option ...Option) (err error) { return } defsys, err = newSys(options) + + defsys.Local().Redis.GetClient().FlushAll(context.TODO()) return }