Redis initializes the Redis connection.
()
| 14 | |
| 15 | // Redis initializes the Redis connection. |
| 16 | func Redis() { |
| 17 | db, _ := strconv.ParseUint(os.Getenv("REDIS_DB"), 10, 64) |
| 18 | client := redis.NewClient(&redis.Options{ |
| 19 | Addr: os.Getenv("REDIS_ADDR"), |
| 20 | Password: os.Getenv("REDIS_PW"), |
| 21 | DB: int(db), |
| 22 | MaxRetries: 1, |
| 23 | }) |
| 24 | |
| 25 | _, err := client.Ping(context.Background()).Result() |
| 26 | |
| 27 | if err != nil { |
| 28 | util.Log().Panic("failed to connect to Redis: %v", err) |
| 29 | } |
| 30 | |
| 31 | RedisClient = client |
| 32 | } |