Skip to content

Making use of a custom predis/redis client #598

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

Closed
dol opened this issue May 7, 2018 · 5 comments
Closed

Making use of a custom predis/redis client #598

dol opened this issue May 7, 2018 · 5 comments

Comments

@dol
Copy link

dol commented May 7, 2018

Configuration:

PhpFastCache version: 6.*
PHP version: PHP 7.0

Issue description:

The predis client can also be used with a Redis cluster/sentinel setup. https://github.com/nrk/predis#cluster
The current implementation and also v7 doesn't allow to use more than one server.

$this->instance = new PredisClient($config);

To allow all the possible predis settings the configurations parameters need to be passed to the client initialization. In v6 and v7 this is not possible due to a limited set of configuration settings and that are merge with the default settings.
One solution could be to pass the raw $parameters and $options to the client initialization inside the driver or the add a new config parameter that allows a already Predis client object.
E.g:

<?php
use phpFastCache\CacheManager;

$parameters = ['tcp://10.0.0.1?alias=master', 'tcp://10.0.0.2', 'tcp://10.0.0.3'];
$options    = ['replication' => true];
$predis = new Predis\Client($parameters, $options);

$config = [
    'predis-client' => $predis,
];

$InstanceCache = CacheManager::getInstance('predis', $config);
@Geolim4
Copy link
Member

Geolim4 commented May 7, 2018

Hello,

This is a known limitation of the (P)redis driver and won't be done in v6 which is now stable.
However this could be eventually studied for the v7.

Cheers,
Georges

@Geolim4 Geolim4 self-assigned this May 7, 2018
@Geolim4 Geolim4 added the 7.0 label May 7, 2018
@Geolim4 Geolim4 changed the title Predis support for cluster option Making use of a custom predis/redis client May 12, 2018
@Geolim4
Copy link
Member

Geolim4 commented May 12, 2018

@dol This should do the job. Test it please, so I can make some automated tests on my side too.
Thanks.
N.b: This has been only implemented for Predis/Redis clients for now. I will may considerate implementing it to other drivers in the future.

@Geolim4
Copy link
Member

Geolim4 commented May 14, 2018

@dol Bump :P

@Geolim4
Copy link
Member

Geolim4 commented May 15, 2018

The issue has been fixed, thanks you for your contribution 👍

Geolim4

@dol
Copy link
Author

dol commented May 17, 2018

@Geolim4 Thank you for implementing this. I was able to the implementation and I confirm it's working as excepted.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants