Skip to content

yriveiro/php-fslock

Folders and files

NameName
Last commit message
Last commit date

Latest commit

59765a6 · Jan 31, 2016

History

34 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

FSLock

Build Status Coverage Status Total Downloads

A simple lock implementation using flock.

Usage

use FSLock\FSLock;

$lock = new FSLock('test');

if ($lock->acquire()) {
    // Critical code.

    $lock->release();
}

API

  • acquire: Acquires the lock, returns true if the operation was successful otherwise the return is false.
  • release: Releases the lock, returns true if the operation was successful otherwise the return is false.
  • destroy: allows manually destruction of the lock. Internally release the lock and perform a cleanup operation. It's the same process used by the __destruct magic method.
  • id: returns the lock id.
  • getPath: returns the lock path

Install

The recommended way to install this package is through Composer.

composer require yriveiro/php-fslock:2.0.0

Tests

Tests are performed using the phpunit library, to run them:

php vendor/bin/phpunit tests

License

FSLock is licensed under MIT license.