You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
22 lines
495 B
22 lines
495 B
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
|
|
}
|
|
}
|