123456789101112131415161718192021222324252627 |
- package global
- import (
- "context"
- "file_upload/backend/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))
- }
- }
|