| 123456789101112131415161718192021222324252627 |
- package redis
- import (
- "github.com/go-redis/redis/v7"
- "video_course/global"
- )
- var client redis.UniversalClient
- func GetRedis() redis.UniversalClient {
- return client
- }
- func Init() (err error) {
- cfg, err := global.Config.GetRedis()
- if err != nil {
- panic(err)
- }
- opt := &redis.UniversalOptions{
- Addrs: cfg.Addrs,
- Password: cfg.Password,
- MasterName: cfg.Mastername,
- }
- client = redis.NewUniversalClient(opt)
- _, err = client.Ping().Result()
- return
- }
|