Package Data | |
---|---|
Maintainer Username: | mingalevme |
Maintainer Contact: | mingalevme@gmail.com (Mingalev Mikhail) |
Package Create Date: | 2017-11-17 |
Package Last Update: | 2017-11-21 |
Language: | PHP |
License: | MIT |
Last Refreshed: | 2024-11-15 15:12:13 |
Package Statistics | |
---|---|
Total Downloads: | 643 |
Monthly Downloads: | 0 |
Daily Downloads: | 0 |
Total Stars: | 0 |
Total Watchers: | 1 |
Total Forks: | 0 |
Total Open Issues: | 0 |
Laravel/Lumen decorator for symfony/lock component
composer require mingalevme/illuminate-lock
.
Register the appropriate service provider \Mingalevme\Illuminate\Lock\LaravelLockServiceProvider::class
or \Mingalevme\Illuminate\Lock\LumenLockServiceProvider::class
.
(Optionally) Add alias to your bootstrap file:
'Lock' => Mingalevme\Illuminate\Lock\Facades\Lock::class,
php artisan vendor:publish --provider="Mingalevme\Illuminate\Lock\LaravelLockServiceProvider" --tag="config"
to publish the config file.
(Optionally) For Lumen copy /vendor/mingalevme/illuminate-lock/config/lock.php
to /config/lock.php
.
Now you are able to use the library:
<?php
use Mingalevme\Illuminate\Lock\Facades\Lock;
$lock = Lock::createLock('resource-id');
if ($lock->acquire()) {
echo "Resource has been locked";
} else {
echo "Could not get lock";
}
or
<?php
use Mingalevme\Illuminate\Lock\Facades\Lock;
$lock = Lock::store('redis')->createLock('resource-id');
if ($lock->acquire()) {
echo "Resource has been locked";
} else {
echo "Could not get lock";
}