mirror of
https://github.com/hanzoai/traces.git
synced 2026-10-30 18:20:41 +00:00
* 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]>
31 lines
758 B
Go
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)
|
|
}
|