eleme / rlock
redis lock
Installs: 38 844
Dependents: 0
Suggesters: 0
Security: 0
Stars: 6
Watchers: 0
Forks: 0
Open Issues: 2
Requires
- php: >=5.3
- predis/predis: ~0.8
Requires (Dev)
- illuminate/support: ~4.0
- mockery/mockery: 0.9.1
- phpunit/phpunit: ~4.0
- silex/silex: ~1.1
This package is not auto-updated.
Last update: 2024-12-21 17:43:22 UTC
README
Redis lock for some atomic opration.
Install With Composer:
"require": { "eleme/rlock": "~0.3" }
Usage
Rlock
<?php use Eleme\Rlock\Lock; use Predis\Client; require_once(__DIR__.'/../vendor/autoload.php'); $redis = new Client(); $lock1 = new Lock($redis, 'lock1'); $lock1->acquire(); // release it by manually or it will be autoreleased. $lock1->release(); // pass some options like timeout and interval. $lock2 = new Lock($redis, 'lock2', array('timeout' => 5000, 'interval' => 500)); echo $lock2->acquire() ? 'true' : 'false', "\n"; // sometimes you may need a non-block lock. $lock3 = new Lock($redis, 'lock3', array('blocking' => false)); echo $lock3->acquire() ? 'true' : 'false', "\n"; $lock4 = new Lock($redis, 'lock3', array('blocking' => false)); echo $lock4->acquire() ? 'true' : 'false', "\n";
Factory
<?php use Eleme\Rlock\Factory; use Predis\Client; require_once(__DIR__.'/../vendor/autoload.php'); $factory = new Factory(new Client); $lock = $factory->make('test');
Extended Predis
<?php use Eleme\Rlock\Predis; require_once(__DIR__.'/../vendor/autoload.php'); $redis = new Predis(); $lock = $redis->lock('lock1'); echo $lock->acquire() ? 'true' : 'fasel', "\n";
Laravel
Service Provider
'Eleme\Rlock\Provider\Laravel\RlockServiceProvider'
Facade
'Rlock' => 'Eleme\Rlock\Provider\Laravel\Facade'