PHPackages                             sacred/prevent-race-condition - 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. [Utility &amp; Helpers](/categories/utility)
4. /
5. sacred/prevent-race-condition

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

sacred/prevent-race-condition
=============================

This package allows you to lock some part of code to prevent race condition.

1.0.2(3y ago)02MITPHPPHP ^8.0

Since Nov 19Pushed 3y ago1 watchersCompare

[ Source](https://github.com/antonsacred/prevent-race-condition)[ Packagist](https://packagist.org/packages/sacred/prevent-race-condition)[ RSS](/packages/sacred-prevent-race-condition/feed)WikiDiscussions main Synced 1mo ago

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

Prevent Race Condition
======================

[](#prevent-race-condition)

[![codecov](https://camo.githubusercontent.com/6a28811a2f5fa89a4365273a31d2c697ba944b82e32422ada8f596f4ef879ef8/68747470733a2f2f636f6465636f762e696f2f67682f616e746f6e7361637265642f6d61747269782d64657465726d696e616e742f6272616e63682f6d61737465722f67726170682f62616467652e7376673f746f6b656e3d43313043484f46585745)](https://codecov.io/gh/antonsacred/prevent-race-condition)

This package allows you to lock some part of code to prevent race condition.

### Install

[](#install)

```
composer require sacred/prevent-race-condition

```

### Basic usage

[](#basic-usage)

You need PSR-6 or PSR-16 cache to use this

```
use PreventRaceCondition\RaceConditionFactory;

// $somePSR16Cache is PSR16 any cache instance
$raceCondition = RaceConditionFactory::fromCacheItemPool($somePSR16Cache);

// or

// $somePSR6Cache is PSR6 any cache instance
$raceCondition = RaceConditionFactory::fromSimpleCache($somePSR6Cache);

while($raceCondition->isBusy('lock-name')) {
    // wait or do something else
}

$raceCondition->lock('lock-name');

// do something

$raceCondition->release('lock-name');
```

###  Health Score

22

—

LowBetter than 23% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity2

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity50

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

1267d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/2ca0d6e4d988ccf5ee64842dbc073af8bb83e160b2372897e21275c1c6b37150?d=identicon)[antonsacred](/maintainers/antonsacred)

---

Top Contributors

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

---

Tags

race-condition-preventionrace-conditionsrace conditionlockprevent

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/sacred-prevent-race-condition/health.svg)

```
[![Health](https://phpackages.com/badges/sacred-prevent-race-condition/health.svg)](https://phpackages.com/packages/sacred-prevent-race-condition)
```

###  Alternatives

[zerkalica/semaphore

This library provides an api for semaphore acquire and release

1119.0k1](/packages/zerkalica-semaphore)[friends-of-hyva/magento2-crawler-session

Prevent crawlers from creating a session

155.8k](/packages/friends-of-hyva-magento2-crawler-session)[nabao/laravel-lock

高性能, 分布式, 并发抢占锁, 队列锁

271.5k](/packages/nabao-laravel-lock)[pudongping/hyperf-wise-locksmith

A mutex library provider for the Hyperf framework, designed to enable serialized execution of PHP code in high-concurrency scenarios.

106.3k2](/packages/pudongping-hyperf-wise-locksmith)

PHPackages © 2026

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