Even though tere are no changes between running the test suite against
3.0 and 2.8, we will stick with the current stable Redis version as
the default target and switch to 3.0 as soon as it will be released.
[ci skip]
Redis 3.0 does not really change much in terms of commands (most of
the ones implemented in the "unstable" branch have been backported to
the "2.8" branch after all) aside from a few cluster-related ones, so
we can bump the default version without worries.
Simply overriding one method of the standard connection factory class,
used internally by Predis, allows developers to use their own custom
connection parameters classes through the whole library.
For example, in order to support Heroku-style URIs one can do:
class HerokuParameters extends Predis\Connection\Parameters
{
protected function filter(array $parameters)
{
if (
isset($parameters['scheme']) &&
$parameters['scheme'] === 'redis'
) {
$parameters['scheme'] = 'tcp';
}
if (isset($parameters['pass'])) {
$parameters['password'] = $parameters['pass'];
}
unset($parameters['user'], $parameters['pass']);
return $parameters;
}
}
class ConnectionFactory extends Predis\Connection\Factory
{
protected function createParameters($parameters)
{
return HerokuParameters::create($parameters);
}
}
$client = new Predis\Client($_ENV['REDISCLOUD_URL'], [
'connections' => new ConnectionFactory()
]);
This idea comes in response to #196, but since we do not want to bake
support for SaaS-specific URIs in Predis this is the best compromise
we can offer leave developers free to implement their own logic for
handling these kind of URIs with the additional benefit of having it
available through the whole library (think of cluster or replication
where you have multiple nodes, thus multiple instances of connection
parameters to create).