28 lines
400 B
Go
28 lines
400 B
Go
package config
|
|
|
|
import (
|
|
"context"
|
|
"fmt"
|
|
"github.com/redis/go-redis/v9"
|
|
)
|
|
|
|
var (
|
|
RDC *redis.Client
|
|
CTX = context.Background()
|
|
)
|
|
|
|
func InitRedis() {
|
|
RDC = redis.NewClient(&redis.Options{
|
|
Addr: fmt.Sprintf("%s:%d", Conf.Redis.Host, Conf.Redis.Port),
|
|
Password: Conf.Redis.Passwd,
|
|
DB: Conf.Redis.DB,
|
|
})
|
|
}
|
|
|
|
func CloseRedis() {
|
|
err := RDC.Close()
|
|
if err != nil {
|
|
panic(err)
|
|
}
|
|
}
|