2022-10-21 18:50:38 +08:00
|
|
|
package service
|
|
|
|
|
|
|
|
import (
|
|
|
|
"fmt"
|
|
|
|
"testing"
|
|
|
|
|
2022-10-31 17:26:15 +08:00
|
|
|
"github.com/1Panel-dev/1Panel/backend/app/dto"
|
|
|
|
"github.com/go-redis/redis"
|
2022-10-21 18:50:38 +08:00
|
|
|
)
|
|
|
|
|
|
|
|
func TestMysql(t *testing.T) {
|
2022-10-31 17:26:15 +08:00
|
|
|
client := redis.NewClient(&redis.Options{
|
2022-11-02 16:28:54 +08:00
|
|
|
Addr: "172.16.10.143:6379",
|
|
|
|
Password: "",
|
2022-10-31 17:26:15 +08:00
|
|
|
DB: 0,
|
|
|
|
})
|
2022-11-02 16:28:54 +08:00
|
|
|
fmt.Println(client.Ping().Result())
|
2022-10-27 23:09:39 +08:00
|
|
|
|
2022-11-02 16:28:54 +08:00
|
|
|
var item dto.RedisPersistence
|
2022-10-31 23:52:39 +08:00
|
|
|
dir, _ := client.ConfigGet("dir").Result()
|
|
|
|
if len(dir) == 2 {
|
|
|
|
if value, ok := dir[1].(string); ok {
|
|
|
|
item.Dir = value
|
2022-10-31 17:26:15 +08:00
|
|
|
}
|
2022-10-31 23:52:39 +08:00
|
|
|
}
|
|
|
|
appendonly, _ := client.ConfigGet("appendonly").Result()
|
|
|
|
if len(appendonly) == 2 {
|
|
|
|
if value, ok := appendonly[1].(string); ok {
|
|
|
|
item.Appendonly = value
|
2022-10-31 17:26:15 +08:00
|
|
|
}
|
2022-10-31 23:52:39 +08:00
|
|
|
}
|
|
|
|
appendfsync, _ := client.ConfigGet("appendfsync").Result()
|
|
|
|
if len(appendfsync) == 2 {
|
|
|
|
if value, ok := appendfsync[1].(string); ok {
|
|
|
|
item.Appendfsync = value
|
2022-10-31 17:26:15 +08:00
|
|
|
}
|
2022-10-31 23:52:39 +08:00
|
|
|
}
|
|
|
|
save, _ := client.ConfigGet("save").Result()
|
|
|
|
if len(save) == 2 {
|
|
|
|
if value, ok := save[1].(string); ok {
|
|
|
|
item.Save = value
|
2022-10-31 17:26:15 +08:00
|
|
|
}
|
|
|
|
}
|
2022-10-31 23:52:39 +08:00
|
|
|
fmt.Println(item)
|
2022-10-25 11:41:19 +08:00
|
|
|
}
|