common/pkg/redis/init.go

17 lines
305 B
Go
Raw Permalink Normal View History

2024-08-29 20:38:48 +08:00
package redis
import "github.com/redis/go-redis/v9"
func InitDefaultRedis() (*redis.Client, error) {
opt, err := LoadDefaultConfig()
if err != nil {
return nil, err
}
rdb := redis.NewClient(&redis.Options{
Addr: opt.Addr,
Password: opt.Password,
DB: opt.DB,
})
return rdb, nil
}