pastuhov/yii2-redis-mutex

Yii2 Redis mutex.

Installs: 18 684

Dependents: 0

Suggesters: 0

Security: 0

Stars: 7

Watchers: 1

Forks: 1

Open Issues: 0

Type:yii2-extension

v0.2.1 2020-01-31 13:52 UTC

This package is not auto-updated.

Last update: 2024-11-02 12:07:37 UTC


README

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 kirill@pastukhov.su instead of using the issue tracker.

Credits

License

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