This commit is contained in:
2023-11-02 04:34:46 +08:00
commit c4548fe498
369 changed files with 40208 additions and 0 deletions

25
client/redis.go Normal file
View 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
}