Skip to content

pastuhov/yii2-redis-mutex

Repository files navigation

Yii2 redis mutex

Build Status Scrutinizer Code Quality Code Coverage Total Downloads

Install

Via Composer

$ composer require pastuhov/yii2-redis-mutex

Features

  • Deadlock free
  • Robust

Disadvantages

  • no spinlock
  • non distributed

Usage

$mutex = \Yii::createObject([
	'class' => \pastuhov\yii2redismutex\RedisMutex::className(),
	'redis' => $redisConnection
]);

$mutexName = 'lock';

if ($mutex->acquire($mutexName)) {
	$value++;
	$mutex->release($mutexName);
}

Testing

$ composer test

or

$ phpunit

Debugging

For debugging purposes use:

$ redis-cli monitor

or

$ tail -f tests/runtime/logs/app.log -n 1000

Security

If you discover any security related issues, please email [email protected] instead of using the issue tracker.

Credits

License

GNU General Public License, version 2. Please see License File for more information.