-
-
Notifications
You must be signed in to change notification settings - Fork 9.6k
Support predis 2.* on cache RedisAdapter #49238
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
Comments
Thank you for this suggestion. |
Still would be useful, don't stale. |
Just to update on this. I started to implement something to support predis 1 and 2, but it became challenging to test. The project depends on pedis 1, and apart from making it require After some time it was hard to find the motivation to continue, as I had a working workaround for my use case. But yeah, ideally this should happen, because predis 1 is no longer maintained AFAIK. Perhaps aiming to support only predis 2 once Symfony 7 releases would simplify things here. |
This is to solve an issue in the Symfony RedisAdapter. See related issue: symfony/symfony#49238
This is to solve an issue in the Symfony RedisAdapter. See related issue: symfony/symfony#49238
Thank you for this suggestion. |
I definitely would 😅 |
PR welcome of course. It'd be great to figure out a way to make the adapter work with both versions of Predis. |
Is there any other scenario where Symfony supports multiple major versions of the same dependency, that I could take a look at? As I mentioned a few months ago, the main challenge is to make sure tests are run with the appropriate predis version. Also, it seems predis v3.0.0 is around the corner, just to make things more interesting 😅 predis 1 seems to still be the most installed version https://packagist.org/packages/predis/predis/stats#major/all, although v2 is slowly catching up. |
We run tests with the lastet and with the lowest supported versions of deps automatically so there is nothing to do to have them installed. Then, test cases would need to be written in a way that can selectively run with v1 or v2 depending on what is installed. (let's see v3 as another future step) |
Hello @nicolas-grekas, to support v1 and v2 following code adjustments can be made: use Predis\Connection\Aggregate\ReplicationInterface as ReplicationInterfaceV1;
use Predis\Connection\Replication\ReplicationInterface as ReplicationInterfaceV2; [...] if ($host instanceof \Predis\Client) {
$connection = $host->getConnection();
if ($connection instanceof ReplicationInterfaceV1) {
$hosts = [$host->getClientFor('master')];
} elseif ($connection instanceof ReplicationInterfaceV2) {
$connection->switchToMaster();
$hosts = [$host];
}
} |
I've tried to fix this and write some tests. Thank you! |
This PR was submitted for the 7.2 branch but it was squashed and merged into the 6.4 branch instead. Discussion ---------- [Cache] Tests for Redis Replication with cache | Q | A | ------------- | --- | Branch? | 6.4 | Bug fix? | yes | New feature? | no | Deprecations? | no | Issues | Fix #49238 | License | MIT Adding Replication of Redis to test config and fix bug Commits ------- 159e6b9 [Cache] Tests for Redis Replication with cache
Description
I was investigating an issue reported to a project where I use predis 2 together with symfony/cache. It was pretty hard to debug as it involved redis sentinels, which is complex to set-up.
After a lot of debugging I have found that the root cause was already reported and supposedly solved some years ago. However, it seemed to be back.
After checking the
RedisTrait
, I have realized the problem is that all the conditions implemented there are valid for predis 1, but some namespaces have changed in predis 2, which makes those conditions never properly trigger.I think it shouldn't be super hard to support both versions. If there's a desire to support predis 2, I can try to give it a try and see how it goes.
Example
No response
The text was updated successfully, but these errors were encountered: