2017 © Pedro Peláez
 

library semaphore

This library provides an api for semaphore acquire and release

image

zerkalica/semaphore

This library provides an api for semaphore acquire and release

  • Tuesday, June 13, 2017
  • by zerkalica
  • Repository
  • 1 Watchers
  • 8 Stars
  • 4,619 Installations
  • PHP
  • 2 Dependents
  • 0 Suggesters
  • 7 Forks
  • 1 Open issues
  • 4 Versions
  • 4 % Grown

The README.md

Millwright semaphore library

This library provides an api for semaphore acquire and release., (*1)

Support adapters: flock, pdo, doctrine/orm, apc, memcached, sem, (*2)

Usage:, (*3)

$adapter   = new \Millwright\Semaphore\Adapter\ApcAdapter;
$semaphore = new \Millwright\Semaphore\Model\SemaphoreManager($adapter);

$ttl = 60; // Time in seconds, used, if script dies and release never called.

$handle = $semaphore->acquire('lock key', $ttl);

// Do something thread-safe

$semaphore->release($handle);

SQL table schema:, (*4)

``` sql CREATE TABLE semaphore__semaphore ( id int(11) NOT NULL AUTO_INCREMENT, expire_date datetime NOT NULL, semaphore_key varchar(255) COLLATE utf8_unicode_ci NOT NULL, PRIMARY KEY (id), UNIQUE KEY semaphore_key_idx (semaphore_key) ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci, (*5)


Example model for doctrine adapter. Doctrine adapter works directrly with sql-table. This model only creates appropriate table. ```php /** * Semaphore entity * * @ORM\Entity() * * @ORM\Table(name="semaphore__semaphore", * uniqueConstraints={@ORM\UniqueConstraint(name="semaphore_key_idx", columns={"semaphore_key"})} * ) */ class Semaphore { /** * @ORM\Column(name="id", type="integer") * @ORM\Id * @ORM\GeneratedValue(strategy="AUTO") */ protected $id; /** * @ORM\Column(name="expire_date", type="datetime", nullable=false) */ protected $date; /** * @ORM\Column(name="semaphore_key", type="string", nullable=false) */ protected $key; }

The Versions

13/06 2017

dev-master

9999999-dev

This library provides an api for semaphore acquire and release

  Sources   Download

MIT

by Stefan Zerkalica

lock util semaphore

13/06 2017

v1.1.1

1.1.1.0

This library provides an api for semaphore acquire and release

  Sources   Download

MIT

by Stefan Zerkalica

lock util semaphore

02/05 2017

v1.1.0

1.1.0.0

This library provides an api for semaphore acquire and release

  Sources   Download

MIT

by Stefan Zerkalica

lock util semaphore

15/04 2015

v1.0.0

1.0.0.0

This library provides an api for semaphore acquire and release

  Sources   Download

MIT

by Stefan Zerkalica

lock util semaphore