2017-25 © Pedro Peláez
 

library lock

Locks library for PHP

image

ivopetkov/lock

Locks library for PHP

  • Thursday, July 12, 2018
  • by ivopetkov
  • Repository
  • 1 Watchers
  • 1 Stars
  • 326 Installations
  • PHP
  • 1 Dependents
  • 0 Suggesters
  • 2 Forks
  • 0 Open issues
  • 9 Versions
  • 55 % Grown

The README.md

Lock

A simple locking library ... that is based on file locking (and that's awesome)., (*1)

Latest Stable Version License, (*2)

Why you need it

Imagine you have two tasks that you do not want to overlap (they modify the same data for example). Using this library will bring you peace of mind., (*3)

Keep in mind

The library uses file locking mechanism to ensure it works correctly. This means that it can be used only on applications/instances/processes that share a common file system. A website on one server does just that., (*4)

Install via Composer

composer require ivopetkov/lock

Usage

Using the following two methods (acquire() and release()) will ensure no two applications/instances/processes execute the code between them., (*5)

<?php
require 'vendor/autoload.php';
use IvoPetkov\Lock;

Lock::acquire('lock1'); // Acquires a lock and pauses other applications/instances/processes until the lock is released.
// Do something awesome
Lock::release('lock1'); // Releases the acquired lock.

Documentation

Full documentation is available as part of this repository., (*6)

Configuration

The default timeout to acquire a lock is 1.5 seconds. You can modify it by calling the following method:, (*7)

Lock::setDefaultLockTimeout(2.5);

The temporary lock files needed by the library are stored in your OS temp dir. You can modify it by calling the following method:, (*8)

Lock::setLocksDir('/some/other/temp/dir/');

If multiple applications use this library, you can call the following methods to prefix the keys provided. This way the different applications can use the same keys without interference., (*9)

Lock::setKeyPrefix('app1');

License

This project is licensed under the MIT License. See the license file for more information., (*10)

Contributing

Feel free to open new issues and contribute to the project. Let's make it awesome and let's do in a positive way., (*11)

Author

This library is created and maintained by Ivo Petkov (ivopetkov.com)., (*12)

The Versions

12/07 2018

dev-master

9999999-dev

Locks library for PHP

  Sources   Download

MIT

The Requires

  • php >=7.0.0

 

The Development Requires

12/07 2018

v0.3.0

0.3.0.0

Locks library for PHP

  Sources   Download

MIT

The Requires

  • php >=7.0.0

 

The Development Requires

22/02 2018

v0.2.5

0.2.5.0

Locks library for PHP

  Sources   Download

MIT

The Requires

  • php >=5.5.0

 

The Development Requires

21/11 2017

v0.2.4

0.2.4.0

Locks library for PHP

  Sources   Download

MIT

The Requires

  • php >=5.5.0

 

The Development Requires

26/08 2017

v0.2.3

0.2.3.0

Locks library for PHP

  Sources   Download

MIT

The Requires

  • php >=5.5.0

 

The Development Requires

18/07 2017

v0.2.2

0.2.2.0

Locks library for PHP

  Sources   Download

MIT

The Requires

  • php >=5.5.0

 

The Development Requires

13/06 2017

v0.2.1

0.2.1.0

Locks library for PHP

  Sources   Download

MIT

The Requires

  • php >=5.5.0

 

The Development Requires

27/05 2017

v0.2.0

0.2.0.0

Locks library for PHP

  Sources   Download

MIT

The Requires

  • php >=5.5.0

 

The Development Requires

27/05 2017

v0.1.0

0.1.0.0

Locks library for PHP

  Sources   Download

MIT

The Requires

  • php >=5.5.0

 

The Development Requires