Download the PHP package cheprasov/php-redis-lock without Composer

On this page you can find all versions of the php package cheprasov/php-redis-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 php-redis-lock

MIT license Latest Stable Version Total Downloads

RedisLock v1.0.3 for PHP >= 5.5

About

RedisLock for PHP is a synchronization mechanism for enforcing limits on access to a resource in an environment where there are many threads of execution. A lock is designed to enforce a mutual exclusion concurrency control policy. Based on redis.

Usage

Create a new instance of RedisLock

Usage for lock a process

Methods

RedisLock :: __construct ( RedisClient $Redis , string $key [, int $flags = 0 ] )


Create a new instance of RedisLock.

Method Pameters
  1. RedisClient $Redis - Instanse of RedisClient
  2. string $key - name of key in Redis storage. Only locks with the same name will compete with each other for lock.
  3. int $flags, default = 0
    • RedisLock::FLAG_DO_NOT_THROW_EXCEPTIONS - use this flag, if you don't want catch exceptions by yourself. Do not use this flag, if you want have a full control on situation with locks. Default behavior without this flag - all Exceptions will be thrown.
Example

bool RedisLock :: acquire ( int|float $lockTime , [ float $waitTime = 0 [, float $sleep = 0.005 ] ] )


Try to acquire lock for $lockTime seconds. If lock has acquired in another thread then we will wait $waitTime seconds, until another thread release the lock. Otherwise method throws a exception (if FLAG_DO_NOT_THROW_EXCEPTIONS is not set) or result. Returns true on success or false on failure.

Method Pameters
  1. int|float $lockTime - The time for lock in seconds, the value must be >= 0.01.
  2. float $waitTime, default = 0 - The time for waiting lock in seconds. Use 0 if you don't wait until lock release.
  3. float $sleep, default = 0.005 - The wait time between iterations to check the availability of the lock.
Example

bool RedisLock :: update ( int|float $lockTime )


Set a new time for lock if it is acquired already. Returns true on success or false on failure. Method can throw Exceptions.

Method Pameters
  1. int|float $lockTime - Please, see description for method RedisLock :: acquire
Example

bool RedisLock :: isAcquired ( )


Check this lock for acquired. Returns true on success or false on failure.

bool RedisLock :: isLocked ( )


Check this lock for acquired and not expired, and active yet. Returns true on success or false on failure. Method can throw Exceptions.

bool RedisLock :: isExists ()


Does lock exists or acquired anywhere? Returns true if lock is exists or false if is not.

Installation

Composer

Download composer:

wget -nc http://getcomposer.org/composer.phar

and add dependency to your project:

php composer.phar require cheprasov/php-redis-lock

Running tests

To run tests type in console:

./vendor/bin/phpunit

Something doesn't work

Feel free to fork project, fix bugs and finally request for pull


All versions of php-redis-lock with dependencies

PHP Build Version
Package Version
Requires php Version >=5.5
cheprasov/php-redis-client Version ^1.7.2
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 cheprasov/php-redis-lock contains the following files

Loading the files please wait ....