Download the PHP package jamescauwelier/psredis without Composer
On this page you can find all versions of the php package jamescauwelier/psredis. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download jamescauwelier/psredis
More information about jamescauwelier/psredis
Files in jamescauwelier/psredis
Package psredis
Short Description Sentinel client for the popular php redis client
License MIT
Informations about the package psredis
PSRedis - Sentinel wrapper for PHP redis clients
NOTE: I am no longer actively maintaining this project and I'm looking for another maintainer to take over from me.
A PHP client for redis sentinel connections as a wrapper on other redis clients. The name stands for PHP Sentinel client for Redis. I am sure other would be more creative in coming up with a name.
Installation
The easiest way to install is by using composer. The package is available on packagist so installing should be as easy as putting the following in your composer file:
Usage
Basic example
The most basic example makes use of the Predis adapter by default. This is the least amount of code needed to get going with PSRedis, although we are making plans to make the configuration more concise in the future.
Auto failover
You have the option of letting the library handle the failover. That means that in case of connection errors, the library will select the new master or reconnect to the existing ones depending of what the sentinels decide is the proper action. After this reconnection, the command will be re-tried, but only once. No option for backoff exists here.
Customizing the adapter
You can choose what kind of client adapter to use or even write your own. If you write your own you need to make sure you implement the \PSRedis\Client\ClientAdapter interface.
Configuring backoff
When we fail to discover the location of the master, we need to back off and try again. The back off mechanism is configurable and you can implement your own by implementing the \PSRedis\Client\BackoffStrategy
Here is an example using the incremental backoff strategy:
Testing
Note: For testing, we still use PHPUnit 3.7 due to a bug in PhpStorm not allowing us to run unit tests from our IDE. See http://youtrack.jetbrains.com/issue/WI-21666
Unit testing
We use PHPUnit for unit testing and Phake for mocking. Both are installed using composer. Running the unit tests can be done using the following command:
Integration testing
Prerequisites
Make sure you have installed these on your machine before running the tests:
Running the tests
Before running the tests you need to setup the VM to run the tests on. Use the following command to bring the box up:
After that, run the integration tests with
You will see some warnings that need to be fixed, but the tests themselves should all pass. The warnings are a result of the reset of the environment just before every integration test.