x
This commit is contained in:
+8
-5
@@ -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连接成功,重启生效!"
|
||||
|
||||
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user