From e0723c0e988e250a965514c57b0c45850be0b0ca Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=93=D0=BE=D0=BB=D0=B8=D0=BA=D0=BE=D0=B2=20Maximillian?= =?UTF-8?q?=20=D0=90=D0=BD=D1=82=D0=BE=D0=BD?= Date: Fri, 2 Oct 2026 15:24:11 +0300 Subject: [PATCH] fix(redis): shorten dial/read/write timeouts and cap retries --- backend/internal/storage/redis/client.go | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/backend/internal/storage/redis/client.go b/backend/internal/storage/redis/client.go index 9680e60..0da6614 100644 --- a/backend/internal/storage/redis/client.go +++ b/backend/internal/storage/redis/client.go @@ -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()