PHPackages                             antriver/ninja-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. [Database &amp; ORM](/categories/database)
4. /
5. antriver/ninja-mutex

ActiveLibrary[Database &amp; ORM](/categories/database)

antriver/ninja-mutex
====================

Simple to use mutex implementation that can use flock, memcache, memcached, mysql or redis for locking

0.6.1(5y ago)037.9k↓40.2%1MITPHPPHP &gt;=5.3.0

Since Feb 21Pushed 3y ago1 watchersCompare

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

READMEChangelogDependencies (5)Versions (13)Used By (0)

[![License](https://camo.githubusercontent.com/e0c62535792bb70781af35ba527b332ba66ae4f6c87464526f5465f8cf8ee8b2/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f6c6963656e73652f617276656e696c2f6e696e6a612d6d757465783f636f6c6f723d696e666f726d6174696f6e616c)](http://opensource.org/licenses/MIT)[![PHP](https://camo.githubusercontent.com/5761f19cc72832c9b6d329cfb8d5c6e529eece5c8ee093ca6969fdb0aee82ad3/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f7068702d762f617276656e696c2f6e696e6a612d6d75746578)](https://packagist.org/packages/arvenil/ninja-mutex)[![Version](https://camo.githubusercontent.com/a52133e558d1a5873a4a31d434a8a6014e2198bd7295e7683cf14e193861573d/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f762f72656c656173652f617276656e696c2f6e696e6a612d6d75746578)](https://github.com/arvenil/ninja-mutex/releases/latest)

[![Build](https://github.com/arvenil/ninja-mutex/workflows/PHP/badge.svg)](https://github.com/arvenil/ninja-mutex/actions?query=workflow%3APHP)

[![Coverage](https://camo.githubusercontent.com/5f48c0aa24ff62f5fa7765fe11f1e93925b2150777ddb5b243a2eebcb2c905bb/68747470733a2f2f696d672e736869656c64732e696f2f7363727574696e697a65722f636f7665726167652f672f617276656e696c2f6e696e6a612d6d757465783f636f6c6f723d73756363657373)](https://scrutinizer-ci.com/g/arvenil/ninja-mutex/?branch=master)[![Quality](https://camo.githubusercontent.com/218b045773e0d55b3effea570ff84799732c75c8a767ac65c7a94214e01d7a80/68747470733a2f2f696d672e736869656c64732e696f2f7363727574696e697a65722f7175616c6974792f672f617276656e696c2f6e696e6a612d6d757465783f636f6c6f723d73756363657373266c6162656c3d7175616c697479)](https://scrutinizer-ci.com/g/arvenil/ninja-mutex/?branch=master)[![Maintainability](https://camo.githubusercontent.com/6228330d5ced428696bebd5425b6a35495fb5c8adde1fb754bbbb5b9ff21faf3/68747470733a2f2f696d672e736869656c64732e696f2f636f6465636c696d6174652f6d61696e7461696e6162696c6974792d70657263656e746167652f617276656e696c2f6e696e6a612d6d757465783f636f6c6f723d73756363657373)](https://codeclimate.com/github/arvenil/ninja-mutex)[![Grade](https://camo.githubusercontent.com/bcedc0a419a9cd3e330e14b3d068fb1c096fa859754596450f86aebaba83c310/68747470733a2f2f696d672e736869656c64732e696f2f73796d666f6e792f692f67726164652f31356335633734382d663864382d346235362d623533362d6132396131353161616336633f636f6c6f723d73756363657373)](https://insight.symfony.com/projects/15c5c748-f8d8-4b56-b536-a29a151aac6c)[![Total Downloads](https://camo.githubusercontent.com/4cd95cd5d69f7c0883fdd71f4a9ec7becad04a49b5781dfe86b3a98d156a27ab/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f617276656e696c2f6e696e6a612d6d757465782e737667)](https://packagist.org/packages/arvenil/ninja-mutex)

About
-----

[](#about)

ninja-mutex is a simple to use mutex implementation for php. It supports different adapters (flock, memcache, mysql, redis, ...) so you can set it up as you wish. All adapters (if set up properly) can be used in multi server environment - in other words lock is shared between web servers.

Usage
-----

[](#usage)

### Mutex

[](#mutex)

First you need to choose an adapter and setup it properly. For example if you choose flock implementation first you need to set up NFS filesystem and mount it on web servers. In this example we will choose memcache adapter:

```
