23 lines
468 B
Go
23 lines
468 B
Go
package redis
|
|
|
|
import (
|
|
"context"
|
|
|
|
"github.com/redis/go-redis/v9"
|
|
"github.com/suyiiyii/hertz101/app/facade/conf"
|
|
)
|
|
|
|
var RedisClient *redis.Client
|
|
|
|
func Init() {
|
|
RedisClient = redis.NewClient(&redis.Options{
|
|
Addr: conf.GetConf().Redis.Address,
|
|
Username: conf.GetConf().Redis.Username,
|
|
Password: conf.GetConf().Redis.Password,
|
|
DB: conf.GetConf().Redis.DB,
|
|
})
|
|
if err := RedisClient.Ping(context.Background()).Err(); err != nil {
|
|
panic(err)
|
|
}
|
|
}
|