update: The code structure is finished, and the project can run successfully

This commit is contained in:
QM303176530
2020-04-05 16:18:19 +08:00
parent 1891c1bcbc
commit 08ff55ffce
13 changed files with 60 additions and 50 deletions

View File

@@ -0,0 +1,22 @@
package initialize
import (
"gin-vue-admin/global"
"github.com/go-redis/redis"
)
func Redis() {
redisCfg := global.GVA_CONFIG.Redis
client := redis.NewClient(&redis.Options{
Addr: redisCfg.Addr,
Password: redisCfg.Password, // no password set
DB: redisCfg.DB, // use default DB
})
pong, err := client.Ping().Result()
if err != nil {
global.GVA_LOG.Error(err)
} else {
global.GVA_LOG.Info("redis connect ping response:", pong)
global.GVA_REDIS = client
}
}