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 4w ago

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 21% 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

[iazaran/smart-cache

Smart Cache is a caching optimization package designed to enhance the way your Laravel application handles data caching. It intelligently manages large data sets by compressing, chunking, or applying other optimization strategies to keep your application performant and efficient.

21114.2k](/packages/iazaran-smart-cache)

PHPackages © 2026

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