github predis/predis v0.6.6
Predis v0.6.6

latest releases: v3.0.0-alpha1, v2.2.2, v2.2.1...
9 years ago

Predis is a flexible and feature-complete PHP client library for Redis. This is a maintenance release for the 0.6 series that features mainly performance improvements and adds some new features. As with previous releases, Predis is also available for PHP 5.2 with an officially supported backport (PHP >= 5.2.6). What follows is an overview of the new features introduced in this new release. For a more in-depth list of changes please see the CHANGELOG.

Please read also the roadmap for future releases paragraph.

New features and changes

New default server profile

The default server profile has been upgraded to Redis 2.2 since there are no changes that would break backwards compatibility in your applications. That said, if you are still using Redis 2.0 (or an older version of Redis) but you want to upgrade Predis, it is advisable to set accordingly the server profile that will be used by the client instance.

Long aliases for Redis commands are no more supported by default, but if you need them you can still require Predis_Compatibility.php which will automatically register new server profiles providing them.

Performance improvements

Performances for this release have been further improved resulting in an average 16% faster processing of multi bulk replies and a bit more throughput for pipelined and non-pipelined commands executed against local Redis instances.

A new lightweight response reader that uses less memory and is a bit faster than the previous one is now being used internally but the old handler-based response reader can be enabled by passing composable as the value for the new reader client option:

$client = new Predis\Client($server, array('reader' => 'composable'));

This option can also accept any class implementing the Predis\IResponseReader interface (e.g. Predis\FastResponseReader), which means that developers can create their own response readers.

A few core classes have also been optimized in order to generate less overhead when creating their instances.

UNIX domain sockets

Users can now connect to local Redis instances using UNIX domain sockets on POSIX systems:

$client = new Predis\Client('unix:///tmp/redis.sock');
$client = new Predis\Client(array('scheme' => 'unix', 'path' => '/tmp/redis.sock'));

Redis commands improvements

SINTERSTORE, SUNIONSTORE, SDIFFSTORE, ZINTERSTORE and ZUNIONSTORE can now accept an array to specify the list of the source keys to be used to populate the destination key:

$client->sinterstore('setOutput', array('setA', 'setB'));
$client->zunionstore('zsetOutput', array('zsetA', 'zsetB', 'zsetC'), $options);

The same applies for commands that simply accept a variable number of keys such as MGET, SINTER, SUNION, SDIFF, SUBSCRIBE and PSUBSCRIBE:

$keys = $client->mget(array('key1', 'key2', 'key3'));
$set = $client->sinter(array('setA', 'setB', 'setC'));
$client->subscribe(array('channel1', 'channel2', 'channel3'));

Notes

Roadmap for future releases (Predis v0.7.0)

Predis 0.7 has been in the works for a while now and the first stable release has been delayed a couple of times, but for very good reasons. Right now it is in a kind of beta stage but it is already being leveraged by a few developers in the wild with success. To cite a few points that will make it an exciting major release:

  • It targets only PHP >= 5.3. If you are still on PHP 5.2 then you will have to stick with Predis 0.6, but you should seriously consider to upgrade since PHP 5.2 is slower and it is not even supported anymore.
  • It is faster and consumes less memory than Predis v0.6.6 by default, with options to make it even faster.
  • The internal API is much more clean and coherent, and almost every class used internally by the library can be easily swapped by custom implementations. Almost nothing has changed in the way Redis commands are exposed by the main client class (using them is as easy as it has always been).
  • It complies with PSR-0 to play nice with many recent PHP frameworks such as Symfony2 (see also the excellent RedisBundle project).
  • It will transparently support Redis cluster (when available) as an option to the current cluster implemented via client-side sharding.

You should expect at least one more patch release for Predis 0.6 finalizing a couple of things before Predis v0.7.0 is officially released as stable.

Downloads

  • PHP 5.3 (mainline):
    TGZ or
    ZIP
  • PHP 5.2 (backport):
    TGZ or
    ZIP

Useful links

Don't miss a new predis release

NewReleases is sending notifications on new releases.