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

[WIP] Build custom Redis client based on the installed extension #509

Closed
wants to merge 7 commits into from

Conversation

phansys
Copy link
Contributor

@phansys phansys commented Mar 16, 2019

Q A
Branch master
Bug fix? no
New feature? yes
BC breaks? no
Deprecations? no
Tests pass? yes
Fixed tickets #399
License MIT
Doc PR n/a

@phansys phansys changed the base branch from master to 2.1 March 16, 2019 01:42
@phansys phansys force-pushed the ticket_399 branch 8 times, most recently from 3bcd5c3 to 9ebf39d Compare March 16, 2019 13:59
@phansys phansys force-pushed the ticket_399 branch 4 times, most recently from 248950d to 0a70ce1 Compare March 18, 2019 15:25
@phansys
Copy link
Contributor Author

phansys commented Mar 18, 2019

I'm trying to use the reflection API in order to introspect the \Redis class, but it seems to fail to get some method arguments. By instance, with pconnect() it doesn't find any argument. Do you know how could I get a valid representation of the class provided by the extension?
Thank you in advance.

@B-Galati
Copy link
Collaborator

Could be an issue similar to phpredis/phpredis#1374

@B-Galati
Copy link
Collaborator

See #442 if you want more details ;-)

before_script: mkdir Snc && ln -s ../ Snc/RedisBundle
before_script:
- mkdir Snc && ln -s ../ Snc/RedisBundle
- php clientbuilder/build_redis_client.php
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am not sure why it is necessary to have that in the CI.

IMHO, the class should be generated at cache warmup then dump into var/cache/snc-redis-bundle and then loaded thanks to a custom autoloader. It's basically what doctrine-bundle is doing for entities.

What do you think?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think that could work only when using DI, but be aware that PhpredisClientFactory doesn't depend on the container.
Also, in my first approach I was thinking to check the generated file in each build in order to detect any change based on the installed Redis version, but I think it doesn't have sense now that the installed versions are set explicitly at Travis config.

@phansys
Copy link
Contributor Author

phansys commented Mar 18, 2019

Thank you for pointing me in the right direction. I've opened phpredis/phpredis#1526 for the described problem.

@B-Galati
Copy link
Collaborator

@phansys Given what was said in the issue, I think we could only support phpredis4 for this feature and have a fallback compatible with phpredis3 only. That's quite easy to do since v3 will not change anymore.
We could provide another one for phpredis2 but it's not important IMHO as it's quite an old version.

@phansys
Copy link
Contributor Author

phansys commented Mar 19, 2019

Sure. I'll try to work on the proposed fix today. Thank you.

@phansys phansys force-pushed the ticket_399 branch 2 times, most recently from 698f559 to f7df8c7 Compare March 19, 2019 15:25
@phansys
Copy link
Contributor Author

phansys commented Mar 19, 2019

Methods like echo() and eval() are present at Redis 3.1.6, but these are not allowed by PHP < 7.0. Should we remove them from the custom client based on that version or should we restrict the usage of the client only for PHP >= 7?
For BC reasons, I think the first option is more suitable for this case, but I'd like to hear your opinion.

@phansys
Copy link
Contributor Author

phansys commented Mar 19, 2019

By the other hand, Redis 4.3.0 seems to be not compatible with 4.2.0 (ref):

Declaration of Snc\RedisBundle\Client\Phpredis\Client4_3_0::psubscribe(array $patterns, $callback) should be compatible with Redis::psubscribe(array $patterns)

Should we ship a client by minor version?

@B-Galati
Copy link
Collaborator

By the other hand, Redis 4.3.0 seems to be not compatible with 4.2.0 (ref):

Declaration of Snc\RedisBundle\Client\Phpredis\Client4_3_0::psubscribe(array $patterns, $callback) should be compatible with Redis::psubscribe(array $patterns)

Should we ship a client by minor version?

For phpredis4 we could only generate the client class on cache warmup so that it would always fit with the installed phpredis version.

We would have static client class only for older phpredis version, (e.g.) v2 and v3.

Methods like echo() and eval() are present at Redis 3.1.6, but these are not allowed by PHP < 7.0. Should we remove them from the custom client based on that version or should we restrict the usage of the client only for PHP >= 7?
For BC reasons, I think the first option is more suitable for this case, but I'd like to hear your opinion.

For v3, the bundle only accepts PHP 7 so let's say we add this feature for V3 only. What do you think?
Which should be released in less than 2 months (I hope).

@phansys
Copy link
Contributor Author

phansys commented Mar 19, 2019

I think your proposal is doable. Regarding the release of v3.0.0, should this PR target master?

@B-Galati
Copy link
Collaborator

Yes master for upcoming V3.

@B-Galati
Copy link
Collaborator

Should we close this PR ?

@phansys
Copy link
Contributor Author

phansys commented Mar 26, 2019

Should we close this PR ?

Yes, closing since this fix will not be accepted as is for 2.x branch.

@phansys phansys closed this Mar 26, 2019
@phansys phansys deleted the ticket_399 branch March 26, 2019 21:12
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