Files
dypid/db/redis.go

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