From 7fe58f372512f04949b7d375a644a6bea6cf7123 Mon Sep 17 00:00:00 2001 From: kzkzzzz Date: Sat, 1 Jun 2024 18:28:09 +0800 Subject: [PATCH] update --- mymysql/mysql.go | 4 ++-- mymysql/mysql_test.go | 2 +- myredis/redis.go | 4 ++-- myredis/redis_test.go | 2 +- 4 files changed, 6 insertions(+), 6 deletions(-) diff --git a/mymysql/mysql.go b/mymysql/mysql.go index bb04458..a66f557 100644 --- a/mymysql/mysql.go +++ b/mymysql/mysql.go @@ -138,12 +138,12 @@ func NewGormLogger(writer gormLogger.Writer, gormLoggerConfig gormLogger.Config) return gormLogger.New(writer, gormLoggerConfig) } -func CloseInstance(key string) { +func CloseDB(key string) { db, _ := DB(key).DB() db.Close() } -func CloseAllInstance() { +func CloseAllDB() { for _, v := range instanceMap { db, _ := v.DB() db.Close() diff --git a/mymysql/mysql_test.go b/mymysql/mysql_test.go index 72d5c61..38b37ea 100644 --- a/mymysql/mysql_test.go +++ b/mymysql/mysql_test.go @@ -20,7 +20,7 @@ func TestMysql(t *testing.T) { return } - defer CloseAllInstance() + defer CloseAllDB() var res = make(map[string]interface{}) err = DB().Table("image").Limit(1).Take(&res).Error diff --git a/myredis/redis.go b/myredis/redis.go index fd72c3a..3783ee0 100644 --- a/myredis/redis.go +++ b/myredis/redis.go @@ -169,11 +169,11 @@ func (r *MyRedis) SetJson(key string, value interface{}, t ...time.Duration) (st return r.Client.Set(ctx, key, v, t2).Result() } -func CloseInstance(key string) { +func CloseDB(key string) { DB(key).Client.Close() } -func CloseAllInstance() { +func CloseAllDB() { for _, v := range instanceMap { v.Client.Close() } diff --git a/myredis/redis_test.go b/myredis/redis_test.go index dd104a6..1c71f05 100644 --- a/myredis/redis_test.go +++ b/myredis/redis_test.go @@ -21,7 +21,7 @@ func TestRedis(t *testing.T) { fmt.Println(err) return } - defer CloseAllInstance() + defer CloseAllDB() set, err := DB().Set(context.Background(), "name", "qwe123", time.Minute).Result() if err != nil {