This commit is contained in:
cdle
2023-06-14 17:05:19 +08:00
parent da24a7ab97
commit bb8bee8ad4
14 changed files with 145 additions and 62 deletions
+1 -1
View File
@@ -72,7 +72,7 @@ func Initsillyplus() storage.Bucket {
}
v := &Bucket{
name: "sillyplus",
name: "sillyGirl",
}
return v
}
+26 -6
View File
@@ -13,6 +13,7 @@ import (
"github.com/beego/beego/v2/client/httplib"
"github.com/buger/jsonparser"
"github.com/cdle/sillyplus/core/logs"
"github.com/cdle/sillyplus/core/storage"
"github.com/cdle/sillyplus/utils"
@@ -69,18 +70,37 @@ func (bucket *Bucket) Type() string {
return "redis"
}
func Try(RedisAddr, RedisPassword string) error {
db := redis.NewClient(&redis.Options{
Addr: RedisAddr,
Password: RedisPassword, // no password set
DB: 0, // use default DB
DialTimeout: time.Second * 5,
})
err := db.Get(context.Background(), "666").Err()
if err == nil {
db.Close()
}
return err
}
func Initsillyplus(RedisAddr, RedisPassword string) storage.Bucket {
db = redis.NewClient(&redis.Options{
Addr: RedisAddr,
Password: RedisPassword, // no password set
DB: 0, // use default DB
Addr: RedisAddr,
Password: RedisPassword, // no password set
DB: 0, // use default DB
DialTimeout: time.Second * 5,
})
if db == nil {
panic("redis is not ok")
err := db.Get(context.Background(), "666").Err()
if err != nil {
logs.Error("redis错误", err)
panic(err)
}
sillyplus = &Bucket{
name: "sillyplus",
name: "sillyGirl",
}
port := sillyplus.GetString("port", "8080")
if utils.SlaveMode {
is, _ := db.ConfigGet(ctx, "slaveof").Result()