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.

24 lines
573 B

package initialize
import (
"pure/global"
"github.com/go-redis/redis"
"go.uber.org/zap"
)
func Redis() {
redisCfg := global.MG_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.MG_LOG.Error("redis connect ping failed, err:", zap.Any("err", err))
} else {
global.MG_LOG.Info("redis connect ping response:", zap.String("pong", pong))
global.MG_REDIS = client
}
}