2017 © Pedro Peláez
 

library redlock-php

Redis distributed locks in PHP

image

dakota/redlock-php

Redis distributed locks in PHP

  • Wednesday, April 4, 2018
  • by dakota
  • Repository
  • 0 Watchers
  • 0 Stars
  • 4,041 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 111 Forks
  • 0 Open issues
  • 12 Versions
  • 99 % Grown

The README.md

redlock-php - Redis distributed locks in PHP, (*1)

This library implements the Redis-based distributed lock manager algorithm described on the Redis website., (*2)

It relies on Credis for Redis connections. Credis offers a native pure-PHP implementation which will automatically switch to using phpredis for improved performance if it's available., (*3)

To create a lock manager:, (*4)


$servers = [ ['127.0.0.1', 6379, 0.01], ['127.0.0.1', 6389, 0.01], ['127.0.0.1', 6399, 0.01], ]; $redLock = new RedLock($servers);

To acquire a lock:, (*5)


$lock = $redLock->lock('my_resource_name', 1000);

Where the resource name is an unique identifier of what you are trying to lock and 1000 is the number of milliseconds for the validity time., (*6)

The returned value is false if the lock was not acquired (you may try again), otherwise an array representing the lock is returned, having three keys:, (*7)

Array
(
    [validity] => 9897.3020019531
    [resource] => my_resource_name
    [token] => 53771bfa1e775
)
  • validity, an integer representing the number of milliseconds the lock will be valid.
  • resource, the name of the locked resource as specified by the user.
  • token, a random token value which is used to safe reclaim the lock.

To release a lock:, (*8)

    $redLock->unlock($lock)

It is possible to setup the number of retries (by default 3) and the retry delay (by default 200 milliseconds) used to acquire the lock., (*9)

The Versions

04/04 2018

dev-master

9999999-dev

Redis distributed locks in PHP

  Sources   Download

MIT

The Requires

 

by Ronny Lopez

04/04 2018

v1.1.0

1.1.0.0

Redis distributed locks in PHP

  Sources   Download

MIT

The Requires

 

by Ronny Lopez

13/10 2017

dev-patch-1

dev-patch-1

Redis distributed locks in PHP

  Sources   Download

The Requires

 

by Ronny Lopez

21/06 2017

v1.0.8

1.0.8.0

Redis distributed locks in PHP

  Sources   Download

The Requires

 

by Ronny Lopez

16/06 2017

v1.0.7

1.0.7.0

Redis distributed locks in PHP

  Sources   Download

The Requires

 

by Ronny Lopez

14/06 2017

v1.0.6

1.0.6.0

Redis distributed locks in PHP

  Sources   Download

The Requires

 

by Ronny Lopez

11/05 2017

v1.0.5

1.0.5.0

Redis distributed locks in PHP

  Sources   Download

The Requires

 

by Ronny Lopez

10/05 2017

v1.0.4

1.0.4.0

Redis distributed locks in PHP

  Sources   Download

The Requires

 

by Ronny Lopez

09/05 2017

v1.0.3

1.0.3.0

Redis distributed locks in PHP

  Sources   Download

The Requires

 

by Ronny Lopez

08/03 2017

v1.0.2

1.0.2.0

Redis distributed locks in PHP

  Sources   Download

The Requires

 

by Ronny Lopez

08/03 2017

v1.0.1

1.0.1.0

Redis distributed locks in PHP

  Sources   Download

The Requires

 

by Ronny Lopez

23/02 2017

v1.0

1.0.0.0

Redis distributed locks in PHP

  Sources   Download

The Requires

 

by Ronny Lopez