Files

28 lines
457 B
Go
Raw Permalink Normal View History

package globals
import (
"github.com/redis/go-redis/v9"
"log/slog"
"net"
"proxy-server/gateway/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)
}
}
}