feat: 首次提交,添加Web界面和Redis支持的数据管理系统
This commit is contained in:
26
db/redis.go
Normal file
26
db/redis.go
Normal file
@@ -0,0 +1,26 @@
|
||||
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初始化完成")
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user