Skip to content

Making use of a custom predis/redis client #598

@dol

Description

@dol

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);

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions