2025-03-18 17:57:07 +08:00
|
|
|
package rds
|
|
|
|
|
|
|
|
|
|
import (
|
|
|
|
|
"net"
|
2025-03-26 14:57:44 +08:00
|
|
|
"platform/pkg/env"
|
2025-03-18 17:57:07 +08:00
|
|
|
|
|
|
|
|
"github.com/redis/go-redis/v9"
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
var Client *redis.Client
|
|
|
|
|
|
|
|
|
|
func Init() {
|
|
|
|
|
Client = redis.NewClient(&redis.Options{
|
|
|
|
|
Addr: net.JoinHostPort(env.RedisHost, env.RedisPort),
|
|
|
|
|
DB: env.RedisDb,
|
|
|
|
|
Password: env.RedisPass,
|
|
|
|
|
})
|
|
|
|
|
}
|
2025-04-01 11:26:37 +08:00
|
|
|
|
|
|
|
|
func Exit() error {
|
|
|
|
|
if Client != nil {
|
|
|
|
|
return Client.Close()
|
|
|
|
|
}
|
|
|
|
|
return nil
|
|
|
|
|
}
|