DelayNoMore/battle_srv/storage/redis_manager.go

30 lines
574 B
Go
Raw Normal View History

2022-09-20 15:50:01 +00:00
package storage
import (
2022-11-09 06:20:26 +00:00
. "battle_srv/common"
2022-09-20 15:50:01 +00:00
"fmt"
"github.com/go-redis/redis"
_ "github.com/go-sql-driver/mysql"
"go.uber.org/zap"
. "dnmshared"
2022-09-20 15:50:01 +00:00
)
var (
RedisManagerIns *redis.Client
)
func initRedis() {
RedisManagerIns = redis.NewClient(&redis.Options{
Addr: fmt.Sprintf("%s:%d", Conf.Redis.Host, Conf.Redis.Port),
Password: Conf.Redis.Password, // no password set
DB: Conf.Redis.Dbname, // use default DB
})
pong, err := RedisManagerIns.Ping().Result()
if nil != err {
panic(err)
}
2022-09-20 15:50:01 +00:00
Logger.Info("Redis", zap.String("ping", pong))
}