重构项目结构,将 orm 和 rds 包迁移到 web/globals

This commit is contained in:
2025-05-10 16:59:41 +08:00
parent 37e6e58816
commit d256359681
60 changed files with 363 additions and 349 deletions

25
web/globals/redis.go Normal file
View File

@@ -0,0 +1,25 @@
package globals
import (
"net"
"platform/pkg/env"
"github.com/redis/go-redis/v9"
)
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() error {
if Redis != nil {
return Redis.Close()
}
return nil
}