ЛР 5 — асинхронная обработка и версии pipeline

This commit is contained in:
2026-11-16 02:38:13 +03:00
parent 276dbdad8a
commit 1f535f1b5b
163 changed files with 17194 additions and 24 deletions
+31
View File
@@ -0,0 +1,31 @@
package database
import (
"context"
"time"
"github.com/redis/go-redis/v9"
)
func NewRedis(ctx context.Context, addr string) (*redis.Client, error) {
options := &redis.Options{
Addr: addr,
DialTimeout: 3 * time.Second,
ReadTimeout: 3 * time.Second,
WriteTimeout: 2 * time.Second,
PoolSize: 10,
PoolTimeout: 2 * time.Second,
ContextTimeoutEnabled: true,
}
client := redis.NewClient(options)
if err := client.Ping(ctx).Err(); err != nil {
_ = client.Close()
return nil, err
}
return client, nil
}