Download the PHP package remi-san/lock without Composer

On this page you can find all versions of the php package remi-san/lock. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package lock

Lock

Author Build Status Quality Score Packagist Version Coverage Status SensioLabsInsight

Description

Lock is a library aimed at providing a simple and reliable way to lock resources.

Main classes

Token Generators

As the Locker will need to generate a unique token to lock the resource, a TokenGenerator interface has been defined, and 2 implementations are available:

Examples:

Quorum

Quorum is used to determinate if enough LockStores have written the lock to consider it really locked.

Two implementations are provided:

Quorum is only used when dealing with multiple stores.

Usage

Create

You can chose between the Single-Store implementation:

Or the Multiple-Store implementation:

Acquire a lock

You can acquire a lock on a resource by providing its name, the ttl, the retry count and the time (in milliseconds) to wait before retrying.

This example will try to lock the resource my_resource_name for 1 second (1000ms) and will retry to acquire it 3 times if it fails the first time (4 in total if all fail), waiting 100ms between each try.

If the lock is acquired, it will return a Lock object describing it.

If it failed being acquired, it will throw a RemiSan\Lock\Exceptions\LockingException.

For the Multiple-Store: The lock will be acquired only if the number of instances that have been able to acquire the lock meet the quorum (the calculation of the quorum is made according to the implementation of Quorum passed to the MultipleInstanceLocker).

Assert if a lock exists

You can ask the Locker if a resource is still locked.

If the resource is still locked (lock has been acquired and ttl hasn't expired), it will return true, it will return false otherwise.

For the Multiple-Store: If at least one connected instance has the lock, it will consider having the lock.

Release a lock

To release a lock you have to provide it to the Locker.

If the lock is still active, it will release it. If it fails but the lock wasn't active anymore, it won't cause any error.

If it fails releasing the lock and the lock is still active, it will throw a RemiSan\Lock\Exceptions\UnlockingException.

For the Multiple-Store: If at least one connected instance fails releasing the lock while still detaining it, the exception will be thrown.

Redis LockStore

Based on Redlock-rb by Salvatore Sanfilippo and ronnylt/redlock-php.

This library implements the Redis-based distributed lock manager algorithm described in this Redis article.

This lib provides a RedisLockStore implementing the RedLock mechanism.

DISCLAIMER: As stated in the original antirez version, this code implements an algorithm which is currently a proposal, it was not formally analyzed. Make sure to understand how it works before using it in your production environments.

Other LockStores

That will come at some point, but it's not there yet.


All versions of lock with dependencies

PHP Build Version
Package Version
Requires php Version >=5.5
ext-redis Version *
symfony/stopwatch Version ^2.6|^3.1
psr/log Version ^1.0
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package remi-san/lock contains the following files

Loading the files please wait ....