网关实现自定义接口安全检查与边缘节点连接权限验证
This commit is contained in:
27
server/globals/redis.go
Normal file
27
server/globals/redis.go
Normal file
@@ -0,0 +1,27 @@
|
||||
package globals
|
||||
|
||||
import (
|
||||
"github.com/redis/go-redis/v9"
|
||||
"log/slog"
|
||||
"net"
|
||||
"proxy-server/server/env"
|
||||
)
|
||||
|
||||
var Redis *redis.Client
|
||||
|
||||
func InitRedis() {
|
||||
Redis = redis.NewClient(&redis.Options{
|
||||
Addr: net.JoinHostPort(env.RedisHost, env.RedisPort),
|
||||
DB: env.RedisDb,
|
||||
Password: env.RedisPass,
|
||||
})
|
||||
}
|
||||
|
||||
func ExitRedis() {
|
||||
if Redis != nil {
|
||||
var err = Redis.Close()
|
||||
if err != nil {
|
||||
slog.Warn("关闭 Redis 连接失败", "err", err)
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user