MCPcopy Create free account
hub / github.com/cortexproject/cortex / NewRedisClient

Function NewRedisClient

pkg/chunk/cache/redis_client.go:54–72  ·  view source on GitHub ↗

NewRedisClient creates Redis client

(cfg *RedisConfig)

Source from the content-addressed store, hash-verified

52
53// NewRedisClient creates Redis client
54func NewRedisClient(cfg *RedisConfig) *RedisClient {
55 opt := &redis.UniversalOptions{
56 Addrs: strings.Split(cfg.Endpoint, ","),
57 MasterName: cfg.MasterName,
58 Password: cfg.Password.Value,
59 DB: cfg.DB,
60 PoolSize: cfg.PoolSize,
61 IdleTimeout: cfg.IdleTimeout,
62 MaxConnAge: cfg.MaxConnAge,
63 }
64 if cfg.EnableTLS {
65 opt.TLSConfig = &tls.Config{InsecureSkipVerify: cfg.InsecureSkipVerify}
66 }
67 return &RedisClient{
68 expiration: cfg.Expiration,
69 timeout: cfg.Timeout,
70 rdb: redis.NewUniversalClient(opt),
71 }
72}
73
74func (c *RedisClient) Ping(ctx context.Context) error {
75 var cancel context.CancelFunc

Callers 1

NewFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected