aboutcoders/resource-lock-bundle

Simple resource locking

0.2.0 2021-02-18 19:36 UTC

This package is not auto-updated.

Last update: 2024-12-21 07:20:07 UTC


README

A Symfony bundle that provides resource lock implementation

Build Status

Installation

Add the AbcResourceLockBundle to your composer.json file

{
    "require": {
        "aboutcoders/resource-lock-bundle": "dev-master"
    }
}

Include the bundle in the AppKernel.php class

public function registerBundles()
{
    $bundles = array(
        // ...
        new Abc\Bundle\ResourceLockBundle\AbcResourceLockBundle(),
    );

    return $bundles;
}

Configuration

Configure the bundle

# app/config/config.yml
abc_resource_lock:
  db_driver: orm

You can define custom managers with a custom prefix within the managers section

# app/config/config.yml
abc_resource_lock:
  db_driver: orm
  managers:
    my_manager:
        prefix: my_prefix
    another_manager:
        prefix: another_prefix

Usage

Use Lock manager to get, set or check locks:

$container->get('abc.resource_lock.lock_manager');

To retrieve the custom manager from the service container you have to specify it by its name:

$container->get('abc.resource_lock.lock_manager_my_manager');

License

The MIT License (MIT). Please see License File for more information.