fix(redis): shorten dial/read/write timeouts and cap retries

This commit is contained in:
Голиков Maximillian Антон
2026-10-02 15:24:11 +03:00
parent 46181bb404
commit e0723c0e98
+6 -5
View File
@@ -14,15 +14,16 @@ func NewClient(url string) (*redis.Client, error) {
return nil, fmt.Errorf("разбор URL: %w", err)
}
opt.DialTimeout = 5 * time.Second
opt.ReadTimeout = 3 * time.Second
opt.WriteTimeout = 3 * time.Second
opt.MaxRetries = 2
opt.DialTimeout = 700 * time.Millisecond
opt.ReadTimeout = 700 * time.Millisecond
opt.WriteTimeout = 700 * time.Millisecond
opt.MaxRetries = 1
opt.PoolSize = 10
opt.ConnMaxIdleTime = time.Minute
client := redis.NewClient(opt)
ctx, cancel := context.WithTimeout(context.Background(), 5*time.Second)
ctx, cancel := context.WithTimeout(context.Background(), 3*time.Second)
defer cancel()
if err := client.Ping(ctx).Err(); err != nil {
_ = client.Close()