package global

import (
	"context"
	"file_upload/simple_zap"
	"fmt"
	"github.com/go-redis/redis/v8"
)

var Rdb *redis.Client

func SetupRedisLink() {
	//addr := RedisSetting.Addr
	//password := RedisSetting.Password
	//db := RedisSetting.DB
	Rdb = redis.NewClient(&redis.Options{
		Addr:     RedisSetting.Addr,
		Password: RedisSetting.Password,
		DB:       0,
	})
	ctx := context.Background()
	_, err := Rdb.Ping(ctx).Result()
	if err != nil {
		simple_zap.WithCtx(context.Background()).Sugar().Warn("redis连接失败", err)
		panic(fmt.Sprintf("redis连接失败:%v", err))
	}
}
