重构项目结构,将 orm 和 rds 包迁移到 web/globals
This commit is contained in:
25
web/globals/redis.go
Normal file
25
web/globals/redis.go
Normal 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
|
||||
}
|
||||
Reference in New Issue
Block a user