achertovsky / yii2-semaphore-mutex
Implementation of semaphore mutex
Installs: 968
Dependents: 0
Suggesters: 0
Security: 0
Stars: 0
Watchers: 1
Forks: 0
Open Issues: 0
pkg:composer/achertovsky/yii2-semaphore-mutex
Requires
- php: >=5.6.1
- yiisoft/yii2: >=2.0.4
This package is auto-updated.
Last update: 2022-05-29 01:55:48 UTC
README
Description
Implementation of mutex through semaphore. Good for providing atomic access
Installing
The preferred way to install this extension is through composer.
{
"require": {
"achertovsky/yii2-semaphore-mutex": "@dev"
}
}
or
composer require achertovsky/yii2-semaphore-mutex "@dev"
Usage
Add to components
[
'components' => [
'mutex' => [
'class' => 'yii\mutex\FileMutex'
],
],
]
Use by
$name = 'test mutex';
//use null to wait infinite or amount of seconds to wait in second param
Yii::$app->mutex->acquire($name, $infiniteWait ? null : 15);
Yii::$app->mutex->release($name);