https://github.com/pastuhov/yii2-redis-mutex
Yii2 Redis mutex
https://github.com/pastuhov/yii2-redis-mutex
cache mutex redis
Last synced: 2 months ago
JSON representation
Yii2 Redis mutex
- Host: GitHub
- URL: https://github.com/pastuhov/yii2-redis-mutex
- Owner: pastuhov
- License: gpl-3.0
- Created: 2016-01-18T12:18:33.000Z (over 9 years ago)
- Default Branch: master
- Last Pushed: 2020-01-31T13:53:29.000Z (over 5 years ago)
- Last Synced: 2025-05-08T05:58:51.889Z (2 months ago)
- Topics: cache, mutex, redis
- Language: PHP
- Homepage:
- Size: 28.3 KB
- Stars: 7
- Watchers: 1
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Yii2 redis mutex
[](https://travis-ci.org/pastuhov/yii2-redis-mutex)
[](https://scrutinizer-ci.com/g/pastuhov/yii2-redis-mutex/?branch=master)
[](https://scrutinizer-ci.com/g/pastuhov/yii2-redis-mutex/?branch=master)
[](https://packagist.org/packages/pastuhov/yii2-redis-mutex)## Install
Via Composer
``` bash
$ composer require pastuhov/yii2-redis-mutex
```## Features
* Deadlock free
* Robust## Disadvantages
* no spinlock
* non distributed## Usage
```php
$mutex = \Yii::createObject([
'class' => \pastuhov\yii2redismutex\RedisMutex::className(),
'redis' => $redisConnection
]);$mutexName = 'lock';
if ($mutex->acquire($mutexName)) {
$value++;
$mutex->release($mutexName);
}
```## Testing
```bash
$ composer test
```
or
```bash
$ phpunit
```## Debugging
For debugging purposes use:
```bash
$ redis-cli monitor
```
or```bash
$ 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
- [Kirill Pastukhov](https://github.com/pastuhov)
- [All Contributors](../../contributors)## License
GNU General Public License, version 2. Please see [License File](LICENSE) for more information.