Skip to content
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

[5.6] Add missing phpredis connection parameters to PhpRedisConnector. #24678

Conversation

SkepticalHippo
Copy link
Contributor

@SkepticalHippo SkepticalHippo commented Jun 24, 2018

At the moment, not all of the connection options are supported for phpredis. Namely, the persistent_id parameter for pconnect and the reserved and retry_interval parameters for connect are missing.

The persistent_id parameter is particularly useful, since multiple connections will use the previous state of the connection, including any options passed via setOption and select operations. Configuring multiple connections with different persistent_id values isolates these.

This PR adds support for the 3 missing parameters in their respective cases via config options.

This doesn't break any backwards compatibility. The order of the parameters has not changed and the additional parameters are added with the defaults from phpredis code. Any previous connections to Redis will remain the same, unless the new parameters are configured.

Note: I suspect Travis is running an old version of Redis, which doesn't support persistent connections. Should this be upgraded or the added it_persists_connection test be removed?

References:

@SkepticalHippo
Copy link
Contributor Author

An update on the previously breaking test:

Travis has PHP_ZTS enabled, which PhpRedis doesn't support for persistent connections (reference). I've added a check for the test. Tests pass fine using the homestead box.

@taylorotwell taylorotwell merged commit a1fc761 into laravel:5.6 Jun 30, 2018
@dzuelke
Copy link

dzuelke commented Jul 5, 2018

This PR is incomplete and introduces a non-existing option.

First, why does this not support the same additional retry_interval option for persistent connections?

According to https://github.com/phpredis/phpredis#pconnect-popen they are identical, and I can confirm from checking the C sources that they are.

Second, reserved is not an option. You're simply supposed to omit the fourth argument by passing NULL.

This is an implementational detail from how both connect() and pconnect() just pass through their arguments to the internal redis_connect(), together with a flag for persistence as the last argument: https://github.com/phpredis/phpredis/blob/4533920fde608e12fe763cf2c977ed711c77e120/redis.c#L872-L921

That fourth argument is persistent_id, which is redundant with non-persistent connections.

@taylorotwell can you please revert this until the issues are addressed?

@dzuelke
Copy link

dzuelke commented Jul 5, 2018

Related-ish: #24748

@dzuelke
Copy link

dzuelke commented Jul 11, 2018

@taylorotwell @SkepticalHippo ?

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.

3 participants