PHPackages                             signe/redlock-php - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Caching](/categories/caching)
4. /
5. signe/redlock-php

ActiveLibrary[Caching](/categories/caching)

signe/redlock-php
=================

Redis distributed locks in PHP

1.1.0(7y ago)11276.9k—0.4%5[2 PRs](https://github.com/signe/redlock-php/pulls)2PHPPHP &gt;= 7.0

Since Oct 14Pushed 7y ago2 watchersCompare

[ Source](https://github.com/signe/redlock-php)[ Packagist](https://packagist.org/packages/signe/redlock-php)[ RSS](/packages/signe-redlock-php/feed)WikiDiscussions master Synced 1mo ago

READMEChangelogDependencies (1)Versions (8)Used By (2)

redlock-php - Redis distributed locks in PHP

Based on [Redlock-rb](https://github.com/antirez/redlock-rb) by [Salvatore Sanfilippo](https://github.com/antirez), descendant of [ronnylt/redlock-php](https://github.com/ronnylt/redlock-php) which was abandoned in early 2015.

This library implements the Redis-based distributed lock manager algorithm [described in this Redis article](http://redis.io/topics/distlock).

To create a lock manager:

Locks can be provided using an array of server tuples made up of the server name (required), connection port (optional), and connection timeout (optional), or by using already-connected Redis objects,

```
$server = new \Redis;
$server->connect('127.0.0.1');

$servers = [
    ['127.0.0.1', 6379, 0.01],
    ['127.0.0.1'],
    $server,
];

$redLock = new RedLock($servers);
```

To acquire a lock:

```
$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.

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:

```
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:

```
    $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.

The retry delay is actually chosen at random between `$retryDelay / 2` milliseconds and the specified `$retryDelay` value.

**Disclaimer**: As stated in the original antirez's 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.

###  Health Score

40

—

FairBetter than 88% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity43

Moderate usage in the ecosystem

Community20

Small or concentrated contributor base

Maturity63

Established project with proven stability

 Bus Factor1

Top contributor holds 62.1% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~190 days

Recently: every ~259 days

Total

7

Last Release

2729d ago

PHP version history (3 changes)1.0PHP ~5.4

1.0.3PHP &gt;= 5.4

1.1.0PHP &gt;= 7.0

### Community

Maintainers

![](https://www.gravatar.com/avatar/1b2c0339b19cbfdd5311ba48e4a78aefd6343f2c75eeed57700bfa514c425081?d=identicon)[signe](/maintainers/signe)

---

Top Contributors

[![signe](https://avatars.githubusercontent.com/u/249456?v=4)](https://github.com/signe "signe (18 commits)")[![tudborg](https://avatars.githubusercontent.com/u/195468?v=4)](https://github.com/tudborg "tudborg (5 commits)")[![ronnylt](https://avatars.githubusercontent.com/u/24546?v=4)](https://github.com/ronnylt "ronnylt (3 commits)")[![joni2back](https://avatars.githubusercontent.com/u/2049935?v=4)](https://github.com/joni2back "joni2back (1 commits)")[![sp-ronny-lopez](https://avatars.githubusercontent.com/u/6653187?v=4)](https://github.com/sp-ronny-lopez "sp-ronny-lopez (1 commits)")[![zeroasterisk](https://avatars.githubusercontent.com/u/23422?v=4)](https://github.com/zeroasterisk "zeroasterisk (1 commits)")

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/signe-redlock-php/health.svg)

```
[![Health](https://phpackages.com/badges/signe-redlock-php/health.svg)](https://phpackages.com/packages/signe-redlock-php)
```

###  Alternatives

[react/cache

Async, Promise-based cache interface for ReactPHP

444112.4M40](/packages/react-cache)[wp-media/wp-rocket

Performance optimization plugin for WordPress

7431.3M3](/packages/wp-media-wp-rocket)[illuminate/cache

The Illuminate Cache package.

12835.6M1.4k](/packages/illuminate-cache)[colinmollenhour/php-redis-session-abstract

A Redis-based session handler with optimistic locking

6325.6M14](/packages/colinmollenhour-php-redis-session-abstract)[cheprasov/php-redis-client

Php client for Redis. It is a fast, fully-functional and user-friendly client for Redis, optimized for performance. RedisClient supports the latest versions of Redis starting from 2.6 to 6.0

1281.2M21](/packages/cheprasov-php-redis-client)[amphp/redis

Efficient asynchronous communication with Redis servers, enabling scalable and responsive data storage and retrieval.

165634.7k44](/packages/amphp-redis)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
