Files
dypid/internal/db/redis.go
YGXB_net 819a2eb8ec
All checks were successful
部署开发环境 / deploy-dev (push) Successful in 8m30s
refactor: 重构项目结构并优化路由组织
2025-10-28 12:20:16 +08:00

27 lines
529 B
Go
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
package db
import (
"dypid/config"
"dypid/global"
"fmt"
"github.com/redis/go-redis/v9"
)
// InitRedis 初始化Redis
func InitRedis() {
global.RDB = redis.NewClient(&redis.Options{
Addr: config.APPConfig.Redis.Host,
Password: config.APPConfig.Redis.Password,
DB: config.APPConfig.Redis.DB,
//PoolSize: 1000,
})
ping := global.RDB.Ping(global.RCtx)
if ping.Err() != nil {
fmt.Println("Redis初始化失败", ping.Err())
panic("Redis error")
} else {
fmt.Println("Redis初始化完成")
}
}