Skip to content

Instantly share code, notes, and snippets.

@nrk
Created July 11, 2010 16:14
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save nrk/471650 to your computer and use it in GitHub Desktop.
Save nrk/471650 to your computer and use it in GitHub Desktop.
Predis 0.6.1 (2010-07-11) - Release notes

Predis 0.6.1 (2010-07-11) - Release notes

Predis is a flexible and feature-complete PHP client library for Redis. This is a maintenance release for the 0.6 series featuring some internal optimizations and a more stable and consistent support for pipelines and transactions (MULTI/EXEC) without any breaking changes. 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.

New features and changes

Transactions (MULTI/EXEC)

Support for dynamic arguments has been added to the Predis\Client::multiExec() method which can also accept an optional array of parameters to initialize the underlying transaction. Moreover, support for the WATCH and UNWATCH commands has been added when using the current development profile (Redis v2.2):

$transaction = $redis->multiExec();
$transaction->watch('foo')->get('foo')->unwatch('foo')->execute();

// or ...

$options = array('watch' => 'foo');
$transaction = $redis->multiExec($options, function($transaction) {
    $transaction->get('foo');
    $transaction->unwatch('foo');
});

See the WATCH and UNWATCH commands in the command reference of Redis for more details.

Command pipelines

Despite having been introduced with 0.6.0, the Predis\Client::pipelineSafe() method has been already deprecated (and might be removed in the next major release) in favour of the usual Predis\Client::pipeline() method with added support for dynamic arguments and an optional array of parameters used to initialize the underlying pipeline. The following lines of code are equivalent:

// the old way, deprecated but still valid for compatibility
$redis->pipelineSafe(function($pipe) { 
    // ... 
});

// the new way
$redis->pipeline(array('safe' => true), function($pipe) { 
    // ... 
});

// get a pipeline object instead of passing a callable
$pipe = $redis->pipeline(array('safe' => true));

Miscellaneous

Predis\MultiExecBlock and Predis\PubSubContext now throw an exception when trying to use features that depend on commands not supported by the server profile that is being used for the client:

$profile = '2.0';    // Redis 2.0 does not support WATCH and UNWATCH
$redis = new Predis\Client('redis://127.0.0.1/', '2.0');
$transaction = $redis->multiExec();
$transaction->watch("foo");    // throws a Predis\ClientException

An exception is also raised when trying to initialize Predis\MultiExecBlock and Predis\PubSubContext using a client connected to a cluster of servers since both work only on single connections.

Optional modifiers for ZRANGE, ZREVRANGE and ZRANGEBYSCORE can now be passed as an associative array to their respective methods. Also, ZRANGEBYSCORE now support the LIMIT modifier:

$redis->zrangebyscore('zsetkey', 1, 100, array(
    'limit'      => array('offset' => 1, 'count' => 2),  // or simply array(1, 2)
    'withscores' => true,
));

Notes

Downloads

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

Useful links

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