mingalevme / illuminate-lock
Laravel/Lumen decorator fot symfony/lock component
1.0.4
2017-11-21 09:58 UTC
Requires
- symfony/lock: ^4.0
Requires (Dev)
- laravel/laravel: ^5.0
- laravel/lumen: ^5.0
- mockery/mockery: ^1.0
- phpunit/php-code-coverage: ^5.2@dev
- phpunit/phpunit: ~6.0
- predis/predis: ^2.0@dev
This package is auto-updated.
Last update: 2024-11-08 01:52:28 UTC
README
Laravel/Lumen decorator for symfony/lock component
Supports drivers:
- Flock
- Memcached
- Redis
- Semaphore
- Combined
- RetryTillSave
Installation
-
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,
- (Optionally) For Larvel run
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"; }