PHPackages                             pastuhov/yii2-redis-mutex - 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. pastuhov/yii2-redis-mutex

ActiveYii2-extension[Caching](/categories/caching)

pastuhov/yii2-redis-mutex
=========================

Yii2 Redis mutex.

v0.2.1(6y ago)727.8k↓42.6%1GPL-2.0PHPPHP &gt;=5.3.0CI failing

Since Jan 19Pushed 6y ago1 watchersCompare

[ Source](https://github.com/pastuhov/yii2-redis-mutex)[ Packagist](https://packagist.org/packages/pastuhov/yii2-redis-mutex)[ Docs](https://github.com/pastuhov/yii2-redis-mutex)[ RSS](/packages/pastuhov-yii2-redis-mutex/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (2)Dependencies (4)Versions (4)Used By (0)

Yii2 redis mutex
================

[](#yii2-redis-mutex)

[![Build Status](https://camo.githubusercontent.com/fc7a19b61160b043b8cd3d1ea4a8c4c8c60114a0c4a85923feeb5f471febbb92/68747470733a2f2f7472617669732d63692e6f72672f7061737475686f762f796969322d72656469732d6d757465782e737667)](https://travis-ci.org/pastuhov/yii2-redis-mutex)[![Scrutinizer Code Quality](https://camo.githubusercontent.com/e8f36ea2aceb081d9fa2c8b69c54918a1f1916ea88a04c1104e1ce494bd8c033/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f7061737475686f762f796969322d72656469732d6d757465782f6261646765732f7175616c6974792d73636f72652e706e673f623d6d6173746572)](https://scrutinizer-ci.com/g/pastuhov/yii2-redis-mutex/?branch=master)[![Code Coverage](https://camo.githubusercontent.com/c62e580e26ca7e71c898005f66092aedd1a3474d94e83ae1b57316e947c5f00b/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f7061737475686f762f796969322d72656469732d6d757465782f6261646765732f636f7665726167652e706e673f623d6d6173746572)](https://scrutinizer-ci.com/g/pastuhov/yii2-redis-mutex/?branch=master)[![Total Downloads](https://camo.githubusercontent.com/a34414fad415eceaa76bfbcb2327cbd1511ed70ebda100b8f57737afdb5d05b8/68747470733a2f2f706f7365722e707567782e6f72672f7061737475686f762f796969322d72656469732d6d757465782f646f776e6c6f616473)](https://packagist.org/packages/pastuhov/yii2-redis-mutex)

Install
-------

[](#install)

Via Composer

```
$ composer require pastuhov/yii2-redis-mutex
```

Features
--------

[](#features)

- Deadlock free
- Robust

Disadvantages
-------------

[](#disadvantages)

- no spinlock
- non distributed

Usage
-----

[](#usage)

```
$mutex = \Yii::createObject([
	'class' => \pastuhov\yii2redismutex\RedisMutex::className(),
	'redis' => $redisConnection
]);

$mutexName = 'lock';

if ($mutex->acquire($mutexName)) {
	$value++;
	$mutex->release($mutexName);
}
```

Testing
-------

[](#testing)

```
$ composer test
```

or

```
$ phpunit
```

Debugging
---------

[](#debugging)

For debugging purposes use:

```
$ redis-cli monitor
```

or

```
$ tail -f tests/runtime/logs/app.log -n 1000
```

Security
--------

[](#security)

If you discover any security related issues, please email  instead of using the issue tracker.

Credits
-------

[](#credits)

- [Kirill Pastukhov](https://github.com/pastuhov)
- [All Contributors](../../contributors)

License
-------

[](#license)

GNU General Public License, version 2. Please see [License File](LICENSE) for more information.

###  Health Score

31

—

LowBetter than 68% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity33

Limited adoption so far

Community10

Small or concentrated contributor base

Maturity50

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 92.3% 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 ~1473 days

Total

2

Last Release

2299d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/7937221?v=4)[Pastuhov Kirill](/maintainers/pastuhov)[@pastuhov](https://github.com/pastuhov)

---

Top Contributors

[![pastuhov](https://avatars.githubusercontent.com/u/7937221?v=4)](https://github.com/pastuhov "pastuhov (12 commits)")[![michkarevev](https://avatars.githubusercontent.com/u/37874234?v=4)](https://github.com/michkarevev "michkarevev (1 commits)")

---

Tags

cachemutexredisredismutexdog pile

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/pastuhov-yii2-redis-mutex/health.svg)

```
[![Health](https://phpackages.com/badges/pastuhov-yii2-redis-mutex/health.svg)](https://phpackages.com/packages/pastuhov-yii2-redis-mutex)
```

###  Alternatives

[jamm/memory

Key-value storage in memory. As a storage can be used: APC, Redis, Memcache, Shared memory. All storage objects have one interface, so you can switch them without changing the working code. Contains PHP Redis client.

13326.3k1](/packages/jamm-memory)[icecave/chastity

Distributed advisory locking for PHP.

1513.3k](/packages/icecave-chastity)[rtckit/react-redlock

Asynchronous distributed locks with Redis and ReactPHP

177.8k1](/packages/rtckit-react-redlock)

PHPackages © 2026

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