rych/lock

Simple lockfile management class.

1.0.0 2014-07-16 01:08 UTC

This package is auto-updated.

Last update: 2024-12-23 11:51:12 UTC


README

Simple process lock management library.

Installation

Installation is best managed via Composer.

{
    "require": {
        "rych/lock": "1.0.*"
    }
}

Or:

composer require rych/lock=1.0.*

Usage

<?php

$lock = new \Rych\Lock\Lock("lock-name", "/path/to/locks");
if ($lock->lock()) {
    // Do work here
} else {
    die ("Unable to acquire lock! Make sure no other process is running!");
}

$lock->unlock();

Methods

  • bool \Rych\Lock\Lock::__construct( string $name [, string $bucket = null ] )
  • bool \Rych\Lock\Lock::lock( [ bool $block = false ] )
  • bool \Rych\Lock\Lock::unlock()
  • bool \Rych\Lock\Lock::check( [ string &$pidof = null ] )