2017 © Pedro Peláez
 

library predis-async

Asynchronous version of Predis

image

predis/predis-async

Asynchronous version of Predis

  • Monday, June 13, 2016
  • by nrk
  • Repository
  • 22 Watchers
  • 297 Stars
  • 110,925 Installations
  • PHP
  • 8 Dependents
  • 1 Suggesters
  • 48 Forks
  • 11 Open issues
  • 7 Versions
  • 5 % Grown

The README.md

Predis\Async

Software license ![Latest stable][ico-version-stable] Latest development ![Monthly installs][ico-downloads-monthly] Build status ![HHVM support][ico-hhvm], (*1)

Asynchronous (non-blocking) version of Predis, the full-featured PHP client library for Redis, built on top of React to handle evented I/O. By default Predis\Async does not require any additional C extension to work, but it can be optionally paired with phpiredis to sensibly lower the overhead of serializing and parsing the Redis protocol., (*2)

Predis\Async is currently under development but already works pretty well. The client foundation is being built on top of the event loop abstraction offered by React, an event-oriented framework for PHP that aims to provide everything needed to create reusable libraries and long-running applications using an evented approach powered by non-blocking I/O. This library is partially tested on HHVM, but support for this runtime should be considered experimental., (*3)

Contributions are highly welcome and appreciated, feel free to open pull-requests with fixes or just report issues if you encounter weird behaviors and blatant bugs., (*4)

Main features

  • Wide range of Redis versions supported (from 2.0 to 3.0 and unstable) using profiles.
  • Transparent key prefixing for all known Redis commands using a customizable prefixing strategy.
  • Abstraction for MULTI / EXEC transactions (Redis >= 2.0).
  • Abstraction for PUBLISH / SUBSCRIBE contexts (Redis >= 2.0).
  • Abstraction for MONITOR contexts (Redis >= 1.2).
  • Abstraction for Lua scripting (Redis >= 2.6).
  • Ability to connect to Redis using TCP/IP or UNIX domain sockets.
  • Redis connections can be established lazily, commands are queued while the client is connecting.
  • Flexible system for defining and registering custom sets of supported commands or profiles.

Installing

Predis\Async is available on Packagist. It is not required to have the phpiredis extension loaded as suggested since the client will work anyway using a pure-PHP protocol parser, but if the extension is detected at runtime then it will be automatically preferred over the slower default. It is possible to force the client to use the pure-PHP protocol parser even when the extension is detected simply by passing ['phpiredis' => false] in the array of client options., (*5)

Example

``` php <?php require DIR.'/../autoload.php';, (*6)

$loop = new React\EventLoop\StreamSelectLoop(); $client = new Predis\Async\Client('tcp://127.0.0.1:6379', $loop);, (*7)

$client->connect(function ($client) use ($loop) { echo "Connected to Redis, now listening for incoming messages...\n";, (*8)

$logger = new Predis\Async\Client('tcp://127.0.0.1:6379', $loop);

$client->pubSubLoop('nrk:channel', function ($event) use ($logger) {
    $logger->rpush("store:{$event->channel}", $event->payload, function () use ($event) {
        echo "Stored message `{$event->payload}` from {$event->channel}.\n";
    });
});

});, (*9)

$loop->run(); ```, (*10)

Differences with Predis

Being an asynchronous client implementation, the underlying design of Predis\Async is different from the one of Predis which is a blocking implementation. Certain features have not been implemented yet (or cannot be implemented at all), just to name a few you will not find the usual abstractions for pipelining commands and creating cluster of nodes using client-side sharding. That said, they share a common style and a few basic classes so if you used Predis in the past you should feel at home., (*11)

Contributing

If you want to work on Predis\Async, it is highly recommended that you first run the test suite in order to check that everything is OK, and report strange behaviours or bugs. When modifying the code please make sure that no warnings or notices are emitted by PHP by running the interpreter in your development environment with the error_reporting variable set to E_ALL | E_STRICT., (*12)

The recommended way to contribute to Predis\Async is to fork the project on GitHub, create new topic branches on your newly created repository to fix or add features (possibly with tests covering your modifications) and then open a new pull request with a description of the applied changes. Obviously you can use any other Git hosting provider of your preference., (*13)

Please follow a few basic commit guidelines before opening pull requests., (*14)

Project

Author

License

The code for Predis\Async is distributed under the terms of the MIT license (see LICENSE)., (*15)

The Versions

13/06 2016

dev-master

9999999-dev http://github.com/nrk/predis-async

Asynchronous version of Predis

  Sources   Download

MIT

The Requires

 

The Development Requires

redis predis nosql

26/10 2014

0.2.x-dev

0.2.9999999.9999999-dev http://github.com/nrk/predis-async

Asynchronous version of Predis

  Sources   Download

MIT

The Requires

 

redis predis nosql

26/10 2014

v0.2.3

0.2.3.0 http://github.com/nrk/predis-async

Asynchronous version of Predis

  Sources   Download

MIT

The Requires

 

redis predis nosql

04/09 2013

v0.2.2

0.2.2.0 http://github.com/nrk/predis-async

Asynchronous version of Predis

  Sources   Download

MIT

The Requires

 

redis predis nosql

27/08 2013

v0.2.1

0.2.1.0 http://github.com/nrk/predis-async

Asynchronous version of Predis

  Sources   Download

MIT

The Requires

 

redis predis nosql

27/07 2013

v0.2.0

0.2.0.0 http://github.com/nrk/predis-async

Asynchronous version of Predis

  Sources   Download

MIT

The Requires

 

redis predis nosql

27/07 2013

v0.1.0

0.1.0.0 http://github.com/nrk/predis-async

Asynchronous version of Predis

  Sources   Download

MIT

The Requires

 

redis predis nosql