2017 © Pedro Peláez
 

library predisque

Disque client based on Predis

image

varspool/predisque

Disque client based on Predis

  • Sunday, May 7, 2017
  • by dominics
  • Repository
  • 0 Watchers
  • 0 Stars
  • 5 Installations
  • PHP
  • 1 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 2 Versions
  • 0 % Grown

The README.md

Predisque

Build Status, (*1)

A Disque client for PHP 7.1+ based on (and depending on) Predis. predis : redis :: predisque : disque, yeah?, (*2)

The library is made up of:, (*3)

  • A set of commands (as in Predis\Command\Command) that you can use with Disque, and a server profile for Predis
  • A Predisque\Client that's set up to use port 7711 and the Disque server profile by default
  • An aggregate connection (Predisque\Connection\Aggregate\DisqueCluster) that handles talking to a Disque cluster as a whole
    • Supports discovery via HELLO
    • Supports retrying commands transparently if they fail with a ConnectionException (so we handle -LEAVING responses by swapping to another node)

Because Predisque is based on a feature-rich Predis core, we get things like pipelining and nice underlying Redis protocol support "for free". (A Disque client library should probably not contain its own native Redis protocol parser.), (*4)

Support for all Disque commands is implemented, including exotic ones like DEBUG, MONITOR, and CLUSTER INFO. See TODO.md for progress on reaching a stable API., (*5)

Not yet stable for production use., (*6)

Usage

The PHP namespace is \Predisque, (*7)

To create a client, instantiate a new \Predisque\Client(string|array $parameters = [], array $options = [])., (*8)

The method signature is similar to a Predis client: the connection parameters (host, port, etc.) come first, and can be given in array or DSN/URI string notation. Then a set of more general options comes after. So, all of the following have the same result (a connection to a single Disque server):, (*9)

$client = new \Predisque\Client();
$client = new \Predisque\Client('tcp://127.0.0.1:7711');
$client = new \Predisque\Client([
    'host' => '127.0.0.1',
    'port' => 7711
]);

Connecting to multiple servers is as easy as passing an array of node details:, (*10)

$client = new \Predisque\Client(['tcp://127.0.0.1:7711', 'tcp://127.0.0.1:7712', 'tcp://127.0.0.1:7713']);

Connection Switching

Only one of these connections will be utilized at a time, but the others will be used if the connection to the first server fails, or if it gives a -LEAVING response. Also, details from the cluster's HELLO response will be used to connect to even further backup nodes (so make sure all nodes are accessible to every client)., (*11)

You can control this behavior with the discover option:, (*12)

php $client = new \Predisque\Client('tcp://127.0.0.1:7711', ['discover' => false]);, (*13)

You can also disable all Disque-specific connection niceties (and the aggregate connection in general), by passing the 'cluster' => false option:, (*14)

php $client = new \Predisque\Client('tcp://127.0.0.1:7711', ['cluster' => false]);, (*15)

Testing

Warning: the test suite uses the DEBUG FLUSHALL command. Do not run the tests against a Disque instance you care about. Running the tests will destroy all data on the disque instance they use. (You won't have the tests if you're just using the client as a dist from composer.), (*16)

To execute the test suite, run e.g. DISQUE_SERVER_PORT=7711 ./vendor/bin/phpunit - the port must be specified, or the unhelpful default of 12345 will be used to prevent accidents., (*17)

The Versions

07/05 2017

dev-master

9999999-dev

Disque client based on Predis

  Sources   Download

MIT

The Requires

 

The Development Requires

06/05 2017

dev-connection

dev-connection

Disque client based on Predis

  Sources   Download

MIT

The Requires

 

The Development Requires