PHPackages                             mmdtl/autolock - 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. mmdtl/autolock

ActiveLibrary[Caching](/categories/caching)

mmdtl/autolock
==============

Redis distributed locks in PHP

0.1.0(9y ago)211[1 PRs](https://github.com/mmdtl/autolock/pulls)MITPHPPHP ^5.3|^7.0

Since Mar 28Pushed 8y ago2 watchersCompare

[ Source](https://github.com/mmdtl/autolock)[ Packagist](https://packagist.org/packages/mmdtl/autolock)[ RSS](/packages/mmdtl-autolock/feed)WikiDiscussions master Synced 4w ago

READMEChangelogDependencies (1)Versions (3)Used By (0)

AutoLock[![Build Status](https://camo.githubusercontent.com/31143e2880e5aa3715bf1fa8150d957e4a4c47626859be342da68688a7ff7fa8/68747470733a2f2f7472617669732d63692e6f72672f6d6d64746c2f6175746f6c6f636b2e7376673f6272616e63683d6d6173746572)](https://travis-ci.org/mmdtl/autolock)[![Code Coverage](https://camo.githubusercontent.com/e8d3aa5554aa1c286f1ab31339c7fdf92c9f0a0946ec085f9fa01ad303d17119/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f6d6d64746c2f6175746f6c6f636b2f6261646765732f636f7665726167652e706e673f623d6d6173746572)](https://scrutinizer-ci.com/g/mmdtl/autolock/?branch=master)
=====================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================

[](#autolock)

AutoLock - Redis distributed locks in PHP

This library implements the RedLock algorithm introduced by [@antirez](http://antirez.com/)

This library implements the Redis-based distributed lock manager algorithm [described in this blog post](http://antirez.com/news/77).

To create a lock manager:

```
$pool = new \AutoLock\Pool(array(
    '192.168.1.1:6379',
    '192.168.1.2:6379',
    '192.168.1.3:6379',
),new \AutoLock\Drivers\PHPRedis());

$manager = new \AutoLock\Manager($pool);
```

To acquire a lock:

```
$lock = $manager->lock('distributed_lock',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 object representing the lock is returned, you should use isExpired method to detect whether the lock is expired now or in certain time:

```
$status = $lock->isExpired();
//$status will be true if the lock is expired or it will be false
$status = $lock->isExpired(3600 * 1000);
//$status will be true if the lock will be expired after 3600 seconds or it will be false
```

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

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

###  Health Score

23

—

LowBetter than 26% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity8

Limited adoption so far

Community8

Small or concentrated contributor base

Maturity49

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% 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

Unknown

Total

1

Last Release

3381d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/7e4769095c468fe9e19963f36597ca095995b028cae412a02a823c0e081d3b33?d=identicon)[mmdtllu](/maintainers/mmdtllu)

---

Top Contributors

[![mmdtl](https://avatars.githubusercontent.com/u/2211748?v=4)](https://github.com/mmdtl "mmdtl (3 commits)")

---

Tags

distributeddistributed-lockslockphpredisredisredlocklock

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/mmdtl-autolock/health.svg)

```
[![Health](https://phpackages.com/badges/mmdtl-autolock/health.svg)](https://phpackages.com/packages/mmdtl-autolock)
```

###  Alternatives

[predis/predis

A flexible and feature-complete Redis/Valkey client for PHP.

7.8k318.6M2.7k](/packages/predis-predis)[malkusch/lock

Mutex library for exclusive code execution.

9479.9M28](/packages/malkusch-lock)[snc/redis-bundle

A Redis bundle for Symfony

1.0k40.4M72](/packages/snc-redis-bundle)[clue/redis-protocol

A streaming Redis protocol (RESP) parser and serializer written in pure PHP.

5214.4M13](/packages/clue-redis-protocol)[rtckit/react-redlock

Asynchronous distributed locks with Redis and ReactPHP

177.8k1](/packages/rtckit-react-redlock)[rtcamp/nginx-helper

Cleans nginx's fastcgi/proxy cache or redis-cache whenever a post is edited/published. Also provides cloudflare edge cache purging with Cache-Tags.

23617.0k1](/packages/rtcamp-nginx-helper)

PHPackages © 2026

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