This commit is contained in:
cdle
2023-06-14 17:51:15 +08:00
parent fd21bdc3b6
commit 9314209c08
2 changed files with 10 additions and 7 deletions
+8 -5
View File
@@ -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连接成功,重启生效!"
+2 -2
View File
@@ -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)