tokenly / laravel-record-lock
A locking library
Installs: 14 972
Dependents: 1
Suggesters: 0
Security: 0
Stars: 2
Watchers: 5
Forks: 0
Open Issues: 0
Requires
- php: >=5.5.0
Requires (Dev)
- phpunit/phpunit: ~4
This package is not auto-updated.
Last update: 2024-12-27 22:15:54 UTC
README
A Laravel library for creating a shared lock across an application. Requires a MySQL database connection.
Installation
Add the Laravel package via composer
composer require tokenly/laravel-record-lock
Add the Service Provider (Laravel <= 5.4 only)
Add the following to the providers
array in your application config:
Tokenly\RecordLock\Provider\RecordLockServiceProvider::class
Use it
use Tokenly\RecordLock\Facade\RecordLock; $lock_id = 'plant-garden-once'; $planted = RecordLock::acquireAndExecute($lock_id, function() { // plant the garden // only one process should do this at a time // other processes will block until this is complete sleep(1); return true; });