✨ Init
This commit is contained in:
25
client/redis.go
Normal file
25
client/redis.go
Normal file
@@ -0,0 +1,25 @@
|
||||
package client
|
||||
|
||||
import (
|
||||
"context"
|
||||
"git.echol.cn/loser/logger/log"
|
||||
"github.com/go-redis/redis/v8"
|
||||
"miniapp/global"
|
||||
)
|
||||
|
||||
var Redis *redis.Client
|
||||
|
||||
func InitRedisClient() {
|
||||
// 初始化连接
|
||||
conn := redis.NewClient(&redis.Options{
|
||||
Addr: global.GVA_CONFIG.Redis.Addr,
|
||||
Password: global.GVA_CONFIG.Redis.Password,
|
||||
DB: global.GVA_CONFIG.Redis.DB,
|
||||
})
|
||||
if err := conn.Ping(context.Background()).Err(); err != nil {
|
||||
log.Panicf("Redis连接初始化失败: %v", err)
|
||||
} else {
|
||||
log.Debug("Redis连接初始化成功")
|
||||
}
|
||||
Redis = conn
|
||||
}
|
Reference in New Issue
Block a user