Skip to content

[12.x] - Redis - Establish connection first, before set the options #55370

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Apr 11, 2025

Conversation

alexmontoanelli
Copy link
Contributor

Hi,

PhpRedisConnector try to set 4 options (max_retries,backoff_algorithm,backoff_base,backoff_cap) before
the connection has been established, and so, the options has no effect at all.

With a single line move, creating the connection/client before, the options then is set successfully on client.

@alexmontoanelli alexmontoanelli changed the title Establish connection first, before set the options [12.x] - Redis - Establish connection first, before set the options Apr 11, 2025
@taylorotwell
Copy link
Member

Don't these values specifically control the amount of retries when connecting though?

@alexmontoanelli
Copy link
Contributor Author

These values are passed to client, in this case \Redis, to controll retries and backoff strategies.

Screenshot 2025-04-11 at 11 08 00

If you set in your database.conf this settings (max_retries, backoff_algorithm), and then run
this code, you get the default values.

` php
$connection = Redis::connection();
$option1 = $connection->client()->getOption(\Redis::OPT_MAX_RETRIES);
$option2 = $connection->client()->getOption(\Redis::OPT_BACKOFF_ALGORITHM);
dump($option1, $option2);

`

//database settings
Screenshot 2025-04-11 at 11 10 21

//code to get driver settings
Screenshot 2025-04-11 at 11 10 46

//return values, before and after the fix
//10,0 (default options for max retries, and backoff), event (with database configure)
//30, 2 (respecting the config file)
Screenshot 2025-04-11 at 11 11 27

@taylorotwell taylorotwell merged commit 64fb35b into laravel:12.x Apr 11, 2025
117 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants