Files
traces/modules/cache/redis/redis.go
23b9676e1e Refactor caching to support multiple independent caches (#3166)
* Refactor

Signed-off-by: Joe Elliott <[email protected]>

* changelog

Signed-off-by: Joe Elliott <[email protected]>

* -1 line. are you happy lint?

Signed-off-by: Joe Elliott <[email protected]>

* i offer this humble sacrifice to appease the linting gods

Signed-off-by: Joe Elliott <[email protected]>

* docs cleanup

Signed-off-by: Joe Elliott <[email protected]>

* Update tempodb/backend/azure/azure_test.go

Co-authored-by: Mario <[email protected]>

* added cache warning. removed comment

Signed-off-by: Joe Elliott <[email protected]>

---------

Signed-off-by: Joe Elliott <[email protected]>
Co-authored-by: Mario <[email protected]>
2023-11-30 07:30:05 -05:00

31 lines
758 B
Go

package redis
import (
"time"
"github.com/go-kit/log"
"github.com/prometheus/client_golang/prometheus"
"github.com/grafana/tempo/pkg/cache"
)
type Config struct {
ClientConfig cache.RedisConfig `yaml:",inline"`
TTL time.Duration `yaml:"ttl"`
}
func NewClient(cfg *Config, cfgBackground *cache.BackgroundConfig, name string, logger log.Logger) cache.Cache {
if cfg.ClientConfig.Timeout == 0 {
cfg.ClientConfig.Timeout = 100 * time.Millisecond
}
if cfg.ClientConfig.Expiration == 0 {
cfg.ClientConfig.Expiration = cfg.TTL
}
client := cache.NewRedisClient(&cfg.ClientConfig)
c := cache.NewRedisCache(name, client, prometheus.DefaultRegisterer, logger)
return cache.NewBackground(name, *cfgBackground, c, prometheus.DefaultRegisterer)
}