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 }