alex/mutexlock

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

MutexLock makes sure that a cron job defined in multiple identical web servers will not execute more than one task at a time. Backed by Redis.

This package's canonical repository appears to be gone and the package has been frozen as a result.

dev-master 2018-02-23 13:51 UTC

This package is not auto-updated.

Last update: 2020-08-07 17:53:32 UTC


README

MutexLock makes sure that a cron job defined in multiple identical web servers will not execute more than one task at a time. Backed by Redis.

sample usage

use Monolog\Logger;
use Monolog\Handler\SyslogHandler;
use Monolog\Formatter\LineFormatter;

$log = new Logger('cron');
$syslog = new SyslogHandler('webapp');
$formatter = new LineFormatter("%channel%.%level_name%: %message%");
$syslog->setFormatter($formatter);
$log->pushHandler($syslog);

MutexLock\Lock::init([
    'logger' => $log,
    'host'   => '127.0.0.1',
    'port'   => '6379',
]);

if (!MutexLock\Lock::set(LOCK_KEY, LOCK_TIME)) {
    return;
}

License

MIT