zerkalica/semaphore-bundle

This bundle integrates semaphore library into symfony

Installs: 1 505

Dependents: 0

Suggesters: 0

Security: 0

Stars: 2

Watchers: 3

Forks: 1

Open Issues: 0

Type:symfony-bundle

dev-master 2012-10-22 08:01 UTC

This package is not auto-updated.

Last update: 2024-12-21 14:12:14 UTC


README

Integrates zerkalica/semaphore library into Symfony2.

Configuration options (config.yaml):

millwright_semaphore:
    try_count: 5 # try count, if lock not acquired
    sleep_time: 1 #sleep time in seconds, if lock not acquired
    adapter: millwright_semaphore.adapter.apc # semaphore adapter name
    #predefined adapters:
    #    millwright_semaphore.adapter.doctrine
    #    millwright_semaphore.adapter.apc
    #    millwright_semaphore.adapter.sem
    #    millwright_semaphore.adapter.flock
    namespace: millwright_semaphore # lock keys namespace

Usage:

/** @var $semaphore \Millwright\Semaphore\Model\SemaphoreManagerInterface */
$semaphore = $container->get('millwright_semaphore.manager');

$handle = $semaphore->acquire('lock key or object', 60 /* lock expire time in seconds */);

// Do something thread-safe

$semaphore->release($handle);