1
0
mirror of https://github.com/1Panel-dev/1Panel.git synced 2025-01-20 08:49:16 +08:00
1Panel/backend/app/service/database_test.go
2022-11-10 10:20:36 +08:00

46 lines
962 B
Go

package service
import (
"fmt"
"testing"
"github.com/1Panel-dev/1Panel/backend/app/dto"
"github.com/go-redis/redis"
)
func TestMysql(t *testing.T) {
client := redis.NewClient(&redis.Options{
Addr: "172.16.10.143:6379",
Password: "",
DB: 0,
})
fmt.Println(client.Ping().Result())
var item dto.RedisPersistence
dir, _ := client.ConfigGet("dir").Result()
if len(dir) == 2 {
if value, ok := dir[1].(string); ok {
item.Dir = value
}
}
appendonly, _ := client.ConfigGet("appendonly").Result()
if len(appendonly) == 2 {
if value, ok := appendonly[1].(string); ok {
item.Appendonly = value
}
}
appendfsync, _ := client.ConfigGet("appendfsync").Result()
if len(appendfsync) == 2 {
if value, ok := appendfsync[1].(string); ok {
item.Appendfsync = value
}
}
save, _ := client.ConfigGet("save").Result()
if len(save) == 2 {
if value, ok := save[1].(string); ok {
item.Save = value
}
}
fmt.Println(item)
}