From 9314209c08b022a9da81fc9929270d14aad47b87 Mon Sep 17 00:00:00 2001 From: cdle Date: Wed, 14 Jun 2023 17:51:15 +0800 Subject: [PATCH] x --- core/bucket.go | 13 ++++++++----- core/storage/redis/init.go | 4 ++-- 2 files changed, 10 insertions(+), 7 deletions(-) diff --git a/core/bucket.go b/core/bucket.go index 9b41f3d..b4d501b 100644 --- a/core/bucket.go +++ b/core/bucket.go @@ -56,8 +56,6 @@ func MakeBucket(name string) storage.Bucket { } }() bkt = redis.Initsillyplus(app.GetString("redis_addr"), app.GetString("redis_password")) - bkt.Set("storage", "redis") - }() } else { if def != "boltdb" { @@ -74,10 +72,15 @@ func MakeBucket(name string) storage.Bucket { err := redis.Try(app.GetString("redis_addr"), app.GetString("redis_password")) if err != nil { message = "Redis连接失败,操作无效:" + err.Error() + return &storage.Final{ + Error: errors.New(message), + } + } else { + return &storage.Final{ + Message: message, + } } - return &storage.Final{ - Error: errors.New(message), - } + }) storage.Watch(app, "redis_addr", func(old, new, _ string) *storage.Final { message := "Redis连接成功,重启生效!" diff --git a/core/storage/redis/init.go b/core/storage/redis/init.go index 90ae1ad..5849370 100644 --- a/core/storage/redis/init.go +++ b/core/storage/redis/init.go @@ -77,7 +77,7 @@ func Try(RedisAddr, RedisPassword string) error { DB: 0, // use default DB DialTimeout: time.Second * 5, }) - err := db.Get(context.Background(), "666").Err() + err := db.HSet(context.Background(), "sillyGirl", "storage", "redis").Err() if err == nil { db.Close() } @@ -92,7 +92,7 @@ func Initsillyplus(RedisAddr, RedisPassword string) storage.Bucket { DialTimeout: time.Second * 5, }) - err := db.Get(context.Background(), "666").Err() + err := db.HSet(context.Background(), "sillyGirl", "storage", "redis").Err() if err != nil { logs.Error("redis错误", err) panic(err)