Cache creates a new instance of cache.Cache
()
| 442 | |
| 443 | // Cache creates a new instance of cache.Cache |
| 444 | func (container *Container) Cache() cache.Cache { |
| 445 | container.logger.Debug("creating cache.Cache") |
| 446 | opt, err := redis.ParseURL(os.Getenv("REDIS_URL")) |
| 447 | if err != nil { |
| 448 | container.logger.Fatal(stacktrace.Propagate(err, fmt.Sprintf("cannot parse redis url [%s]", os.Getenv("REDIS_URL")))) |
| 449 | } |
| 450 | if strings.HasPrefix(os.Getenv("REDIS_URL"), "rediss://") { |
| 451 | opt.TLSConfig = &tls.Config{ |
| 452 | MinVersion: tls.VersionTLS12, |
| 453 | } |
| 454 | } |
| 455 | |
| 456 | redisClient := redis.NewClient(opt) |
| 457 | |
| 458 | // Enable tracing instrumentation. |
| 459 | if err = redisotel.InstrumentTracing(redisClient); err != nil { |
| 460 | container.logger.Error(stacktrace.Propagate(err, "cannot instrument redis tracing")) |
| 461 | } |
| 462 | |
| 463 | // Enable metrics instrumentation. |
| 464 | if err = redisotel.InstrumentMetrics(redisClient); err != nil { |
| 465 | container.logger.Fatal(stacktrace.Propagate(err, "cannot instrument redis metrics")) |
| 466 | } |
| 467 | |
| 468 | return cache.NewRedisCache(container.Tracer(), redisClient) |
| 469 | } |
| 470 | |
| 471 | // FirebaseAuthClient creates a new instance of auth.Client |
| 472 | func (container *Container) FirebaseAuthClient() (client *auth.Client) { |
no test coverage detected