27 lines
529 B
Go
27 lines
529 B
Go
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初始化完成")
|
||
}
|
||
}
|