Download the PHP package warmans/dlock without Composer

On this page you can find all versions of the php package warmans/dlock. 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 dlock

Dlock

Build Status Scrutinizer Code Quality Code Coverage

Distributed locking library for PHP. This library allows a process to be locked across multiple servers using a cache server (Redis or Memcache).

The example use case is where you have a process that must happen e.g. hourly but cannot be duplicated such as an import. In this case all of your application servers can be setup with the import job but each hour only one (the one with the fastest system clock) will be able to acquire the lock so all the others will fail. If any server goes offline another will acquire the lock and imports will continue as normal.

Like most distributed systems care should be taken to maintain consistent system clocks across severs. If servers have clocks that are more inconsistent than the time it takes to run a job you may still duplicate jobs. To avid this you could store a globally unique identifier for a job somewhere (e.g. in a redis set) and simply check that a job hasn't already been done after locking (note: not before or you have a race condition).

Locking is achieved using atomic functions to avoid race conditions. To discourage the user creating their own race conditions there is no "isLocked" functionality. You must always attempt to create a lock to deterine the locked status.

Usage

Allow lock to handle locking/unlocking automatically using locked() method:

Alternatively manage it yourself:

Finally if you want to wait for a lock to become available you can use a blocking lock:

Options

The third optional argument of the Lock's constructor is an options array. The options are as follows:

Option Default Description
ds_key_prefix dlock Prefix used by cache key in datastore

Adapters

Any class that implements the DatastoreInterface can be used as an adapter:

Included implementations are as follows:

Memcache

Redis

Running the tests

Tests are split into two testcases; unit and integration. Integration tests require a running Redis and Memcache server on your localhost.

To run all from root directory:

phpunit

To run just unit tests:

phpunit --testsuite=unit

To run just integration tests:

phpunit --testsuite=integration

All versions of dlock with dependencies

PHP Build Version
Package Version
Requires php Version >=5.3.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 warmans/dlock contains the following files

Loading the files please wait ....