simple-as-fuck/laravel-lock

There is no license information available for the latest version (0.2.11) of this package.

Laravel integration for symfony/lock.

0.2.11 2024-03-17 21:17 UTC

This package is auto-updated.

Last update: 2024-04-17 21:30:46 UTC


README

Laravel integration for symfony/lock.

Installation

composer require simple-as-fuck/laravel-lock

Configuration

Add into your .env_example and configure your environment on server.

LOCK_STORE=semaphore

Support

If any PHP platform requirements in composer.json ends with security support, consider package version as unsupported except last version.

PHP supported versions.

Supported symfony lock store are only with native blocking lock, because it is fucking effective.

  • semaphore SemaphoreStore recommended for simple production without application server replication (lock are stored in local ram)

  • flock FlockStore recommended for local development, (lock are stored in local filesystem, so it should work everywhere)

  • pgsql PostgreSqlStore recommended for big production with application server replication (lock are stored remotely by postgres database), you can use special database for locks using setting laravel database connection name LOCK_PGSQL_STORE_CONNECTION=some_postgers_connection_name, by default is used default database connection

Usage

/** @var \SimpleAsFuck\LaravelLock\Service\LockManager $lockManager */
$lockManager = app()->make(\SimpleAsFuck\LaravelLock\Service\LockManager::class);

$lock = $lockManager->acquire('some_lock_key');
try {
    //happy run some critical code synchronously
} finally {
    $lock->release();
}