启动时清空redis

This commit is contained in:
wh_zcy 2022-09-09 18:28:12 +08:00
parent 19ccac6357
commit 51177dd525
5 changed files with 24 additions and 1 deletions

View File

@ -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)
}

View File

@ -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)
}

View File

@ -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 {

View File

@ -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)
}

View File

@ -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
}