You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

27 lines
528 B
Go

package client
import (
"context"
"git.echol.cn/loser/logger/log"
"github.com/go-redis/redis/v8"
"online_code/config"
)
var Redis *redis.Client
func InitRedisClient() {
conf := config.Scd.Redis
// 初始化连接
conn := redis.NewClient(&redis.Options{
Addr: conf.GetDSN(),
Password: conf.Password,
DB: conf.Db,
})
if err := conn.Ping(context.Background()).Err(); err != nil {
log.Panicf("Redis连接初始化失败: %v", err)
} else {
log.Debug("Redis连接初始化成功")
}
Redis = conn
}