MCPcopy Index your code
hub / github.com/NdoleStudio/httpsms / Cache

Method Cache

api/pkg/di/container.go:444–469  ·  view source on GitHub ↗

Cache creates a new instance of cache.Cache

()

Source from the content-addressed store, hash-verified

442
443// Cache creates a new instance of cache.Cache
444func (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
472func (container *Container) FirebaseAuthClient() (client *auth.Client) {

Callers 3

Calls 4

TracerMethod · 0.95
DebugMethod · 0.65
FatalMethod · 0.65
ErrorMethod · 0.65

Tested by

no test coverage detected