PHPackages                             herroffizier/yiicachemutex - 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. herroffizier/yiicachemutex

ActiveLibrary[Caching](/categories/caching)

herroffizier/yiicachemutex
==========================

Mutex implementation based on Yii cache component

1312PHP

Since Mar 17Pushed 12y ago1 watchersCompare

[ Source](https://github.com/herroffizier/yiicachemutex)[ Packagist](https://packagist.org/packages/herroffizier/yiicachemutex)[ RSS](/packages/herroffizier-yiicachemutex/feed)WikiDiscussions master Synced today

READMEChangelogDependenciesVersions (1)Used By (0)

YiiCacheMutex
=============

[](#yiicachemutex)

**YiiCacheMutex** is a mutex implementation for Yii framework based on Yii cache component.

Usage
-----

[](#usage)

First, copy files from this repo to `extensions/yiicachemutex` and add **YiiCacheMutex** to Yii application:

```
return array(
...
    'components'=>array(
        ...
        'cacheMutex' => array(
            'class' => 'ext.yiicachemutex.YiiCacheMutex',
            // Cache component name.
            // Useful when you want to use separate cache for mutexes.
            'cacheName' => 'cache',
            // Time in microseconds to sleep between cache pollings.
            'sleepTime' => 100,
            // Time in seconds for mutex to expire.
            // If set to 0 mutex will never expire but this is not recommended.
            'expireTime' => 300,
        ),
        ...
    ),
...
);
```

After that you can create mutexes by calling `Yii::app()->cacheMutex->acqiure()` and release them by calling `Yii::app()->cacheMutex->release()`. Mutex acquiring may be blocking or nonblocking. For blocking acquiring a timeout may be set. Also mutexes may have expire time which is highly recommended to avoid deadlocks.

Usage examples:

```
// Get mutex 'test' if it's free, otherwise wait for it's release forever.
Yii::app()->cacheMutex->acquire('test');

// Get mutex 'test' if it's free, otherwise return false immeditely.
Yii::app()->cacheMutex->acquire('test', 0);

// Wait 0.5s for mutex 'test' to be released.
Yii::app()->cacheMutex->acquire('test', 500000);

// Release acquired by current thread mutex 'test'.
Yii::app()->cacheMutex->release('test');
```

###  Health Score

22

—

LowBetter than 22% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity10

Limited adoption so far

Community9

Small or concentrated contributor base

Maturity41

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.

### Community

Maintainers

![](https://www.gravatar.com/avatar/820232d3f5de11b08332a98ca93b025ab46d7e3563ddaec2ce6d042828718983?d=identicon)[herroffizier](/maintainers/herroffizier)

---

Top Contributors

[![korotin](https://avatars.githubusercontent.com/u/277992?v=4)](https://github.com/korotin "korotin (6 commits)")

### Embed Badge

![Health badge](/badges/herroffizier-yiicachemutex/health.svg)

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

###  Alternatives

[predis/predis

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

7.8k305.7M2.4k](/packages/predis-predis)[snc/redis-bundle

A Redis bundle for Symfony

1.0k39.4M67](/packages/snc-redis-bundle)[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)

PHPackages © 2026

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