mattdanger / phalcon-semaphore
Simple semaphore component for Phalcon v1.4.x
Installs: 518
Dependents: 0
Suggesters: 0
Security: 0
Stars: 0
Watchers: 2
Forks: 0
Open Issues: 0
pkg:composer/mattdanger/phalcon-semaphore
Requires
- php: >=5.4.0
This package is not auto-updated.
Last update: 2025-10-11 23:54:07 UTC
README
Simple semaphore component for Phalcon PHP
Requirements
- Phalcon v1.4.x
Installation
Install using Composer:
{ "require": { "mattdanger/phalcon-semaphore": "1.*" } }
Create a database table semaphore
with this schema:
CREATE TABLE `semaphore` ( `name` varchar(255) NOT NULL DEFAULT '', `value` varchar(255) DEFAULT NULL, `timestamp` datetime DEFAULT NULL, PRIMARY KEY (`name`) ) ENGINE=InnoDB DEFAULT CHARSET=latin1;
Then add the service:
$di->set('semaphore', '\PhalconSemaphore\Semaphore');
If you want to use a different database table name you can initialize the service like this:
$di->set('semaphore', function() use ($config){ return new \PhalconSemaphore\Semaphore('my_table_name'); }, true);
Usage
$this->semaphore->run(string $class, $string method, int $expiration_hours, array $args); // Example without method parameters $this->semaphore->run('MyNamespace\Models\Stat', 'calculate', 1); // Example with method parameters $this->semaphore->run('MyNamespace\Models\Stat', 'calculate', 1, array($arg1, $arg2, ...));