irediscent / irediscent
Lightweight php handler for iredis with redisent fallback
This package's canonical repository appears to be gone and the package has been frozen as a result.
Installs: 5 430
Dependents: 1
Suggesters: 0
Security: 0
Stars: 4
Watchers: 3
Forks: 0
Open Issues: 0
Requires (Dev)
- satooshi/php-coveralls: dev-master
README
Lightweight php handler for iredis with redisent fallback
##Installation
Install via composer
#Add the following to your `composer.json`
{
"require": {
"irediscent/irediscent": "1.*"
}
}
##Usage
Basic usage
$redis = new Irediscent();
$redis->set('test',1);
echo $redis->get('test'); // 1
Pipeline
$redis = new Irediscent();
$redis->pipeline(function($redis){
$redis->set('foo',1);
$redis->set('bar',2);
});
//Or
$redis->pipeline();
$redis->set('foo',1);
$redis->set('bar',2);
$redis->uncork();
Pipelined MultiExec
$redis = new Irediscent();
$redis->multiExec(function($redis){
$redis->set('foo',1);
$redis->set('bar',2);
});
Standard multi exec
$redis->multi();
$redis->set('foo',1);
$redis->set('bar',2);
$redis->exec();
##Redis Sentinel
Irediscent is capable of working with redis servers in a sentiel cluster out of the box, using SentinelProvider
DSN provider.
The provider will attempt to connect to each sentinel instance in turn until it reaches an active sentinel, and retreive information about the master/slave setup.
The resolved DSN string will then be passed into the connection object. If the redis cluster master configuration changes during the life time of the connection, a "Cannot write against a read-only slave" error may be returned from the redis server, that was previously the master. Irediscent will handle this error, re-interrogate the sentinels and recommit the write action against the new master.
$sentinels = array(
'127.0.0.1:26377',
'127.0.0.1:26378',
'127.0.0.1:26379',
);
$redis = new Irediscent\IrediscentSentinelReplication($sentinels, 'mymaster');