redis.go 545 B

1234567891011121314151617181920212223242526
  1. package global
  2. import (
  3. "Ic_ouath/configs"
  4. "Ic_ouath/simple_zap"
  5. "context"
  6. "github.com/go-redis/redis/v8"
  7. )
  8. var Rdb *redis.Client
  9. func SetupRedisLink() {
  10. //addr := RedisSetting.Addr
  11. //password := RedisSetting.Password
  12. //db := RedisSetting.DB
  13. Rdb = redis.NewClient(&redis.Options{
  14. Addr: configs.Config.GetString("redis.addr"),
  15. Password: "",
  16. DB: 0,
  17. })
  18. ctx := context.Background()
  19. _, err := Rdb.Ping(ctx).Result()
  20. if err != nil {
  21. simple_zap.WithCtx(context.Background()).Sugar().Warn("redis连接失败", err)
  22. }
  23. }