PHPackages                             spiral/lock-bridge - 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. spiral/lock-bridge

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

spiral/lock-bridge
==================

This package provides a integration bridge for the RoadRunner Lock.

1.x-dev(2y ago)00MITPHPPHP ^8.1

Since Jul 17Pushed 2y ago3 watchersCompare

[ Source](https://github.com/spiral/lock-bridge)[ Packagist](https://packagist.org/packages/spiral/lock-bridge)[ Docs](https://spiral.dev/)[ RSS](/packages/spiral-lock-bridge/feed)WikiDiscussions 1.x Synced 1mo ago

READMEChangelogDependencies (8)Versions (1)Used By (0)

RoadRunner Lock Bridge
======================

[](#roadrunner-lock-bridge)

[![PHP Version Require](https://camo.githubusercontent.com/43b95a0be47825619ac5677f2414c1ef58936550fe6f9615b45adcdce71e2a79/68747470733a2f2f706f7365722e707567782e6f72672f73706972616c2f6c6f636b2d6272696467652f726571756972652f706870)](https://packagist.org/packages/spiral/lock-bridge)[![Latest Stable Version](https://camo.githubusercontent.com/d6cf432e40d7382477907315ed3f515491d51430520efbe93b3ecb8c3e22dfda/68747470733a2f2f706f7365722e707567782e6f72672f73706972616c2f6c6f636b2d6272696467652f762f737461626c65)](https://packagist.org/packages/spiral/lock-bridge)[![phpunit](https://github.com/spiral/lock-bridge/actions/workflows/phpunit.yml/badge.svg)](https://github.com/spiral/lock-bridge/actions)[![psalm](https://github.com/spiral/lock-bridge/actions/workflows/psalm.yml/badge.svg)](https://github.com/spiral/lock-bridge/actions)[![Codecov](https://camo.githubusercontent.com/fe2a58e980b259809915529fe79abb56a78dfb7a77c9e883f6d66987ed9caeb8/68747470733a2f2f636f6465636f762e696f2f67682f73706972616c2f6c6f636b2d6272696467652f6272616e63682f312e782f67726170682f62616467652e737667)](https://codecov.io/gh/spiral/lock-bridge/)[![Total Downloads](https://camo.githubusercontent.com/4d280bda0f7e862e1ca4f8f3ee028ac77ac1158caa643699b4dedf5e1d4e1d87/68747470733a2f2f706f7365722e707567782e6f72672f73706972616c2f6c6f636b2d6272696467652f646f776e6c6f616473)](https://packagist.org/spiral/lock-bridge/phpunit)[![](https://camo.githubusercontent.com/4442b73a11753b80fdd7b442ddbfaf8383902c8b9ffa66ed1718e8c62e102f2e/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f646973636f72642d636861742d6d6167656e74612e737667)](https://discord.gg/8bZsjYhVVk)

This package provides a integration bridge for the RoadRunner Lock, which allows for easy management of distributed locks in Spiral Framework. The package provides a fast, lightweight, and reliable way to acquire, release, and manage locks in a distributed environment, making it ideal for use in high-traffic web applications and microservices.

Requirements
------------

[](#requirements)

Make sure that your server is configured with following PHP version and extensions:

- PHP 8.1+
- Spiral Framework 3.7+

Installation
------------

[](#installation)

You can install the package via composer:

```
composer require spiral/lock-bridge
```

After package install you need to register bootloader from the package.

```
protected const LOAD = [
    // ...
    \Spiral\LockBridge\Bootloader\LockBootloader::class,
];
```

> **Note**If you are using [`spiral-packages/discoverer`](https://github.com/spiral-packages/discoverer), you don't need to register bootloader by yourself.

Usage
-----

[](#usage)

```
use RoadRunner\Lock\LockInterface;

$lock = $container->get(LockInterface::class);
```

### Acquire lock

[](#acquire-lock)

Locks a resource so that it can be accessed by one process at a time. When a resource is locked, other processes that attempt to lock the same resource will be blocked until the lock is released.

```
$id = $lock->lock('pdf:create');

// Acquire lock with ttl - 10 seconds
$id = $lock->lock('pdf:create', ttl: 10);
// or
$id = $lock->lock('pdf:create', ttl: new \DateInterval('PT10S'));

// Acquire lock and wait 5 seconds until lock will be released
$id = $lock->lock('pdf:create', wait: 5);
// or
$id = $lock->lock('pdf:create', wait: new \DateInterval('PT5S'));

// Acquire lock with id - 14e1b600-9e97-11d8-9f32-f2801f1b9fd1
$id = $lock->lock('pdf:create', id: '14e1b600-9e97-11d8-9f32-f2801f1b9fd1');
```

### Acquire read lock

[](#acquire-read-lock)

Locks a resource for shared access, allowing multiple processes to access the resource simultaneously. When a resource is locked for shared access, other processes that attempt to lock the resource for exclusive access will be blocked until all shared locks are released.

```
$id = $lock->lockRead('pdf:create', ttl: 10);
// or
$id = $lock->lockRead('pdf:create', ttl: new \DateInterval('PT10S'));

// Acquire lock and wait 5 seconds until lock will be released
$id = $lock->lockRead('pdf:create', wait: 5);
// or
$id = $lock->lockRead('pdf:create', wait: new \DateInterval('PT5S'));

// Acquire lock with id - 14e1b600-9e97-11d8-9f32-f2801f1b9fd1
$id = $lock->lockRead('pdf:create', id: '14e1b600-9e97-11d8-9f32-f2801f1b9fd1');
```

### Release lock

[](#release-lock)

Releases an exclusive lock or read lock on a resource that was previously acquired by a call to `lock()`or `lockRead()`.

```
// Release lock after task is done.
$lock->release('pdf:create', $id);

// Force release lock
$lock->forceRelease('pdf:create');
```

### Check lock

[](#check-lock)

Checks if a resource is currently locked and returns information about the lock.

```
$status = $lock->exists('pdf:create');
if($status) {
    // Lock exists
} else {
    // Lock not exists
}
```

### Update TTL

[](#update-ttl)

Updates the time-to-live (TTL) for the locked resource.

```
// Add 10 seconds to lock ttl
$lock->updateTTL('pdf:create', $id, 10);
// or
$lock->updateTTL('pdf:create', $id, new \DateInterval('PT10S'));
```

Testing
-------

[](#testing)

```
composer test
```

License
-------

[](#license)

The MIT License (MIT). Please see [License File](LICENSE) for more information.

###  Health Score

17

—

LowBetter than 6% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity0

Limited adoption so far

Community8

Small or concentrated contributor base

Maturity36

Early-stage or recently created project

 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

1036d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/796136?v=4)[Anton Tsitou](/maintainers/wolfy-j)[@wolfy-j](https://github.com/wolfy-j)

---

Top Contributors

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

---

Tags

lockspiral

###  Code Quality

TestsPHPUnit

Static AnalysisPsalm

Code StylePHP CS Fixer

Type Coverage Yes

### Embed Badge

![Health badge](/badges/spiral-lock-bridge/health.svg)

```
[![Health](https://phpackages.com/badges/spiral-lock-bridge/health.svg)](https://phpackages.com/packages/spiral-lock-bridge)
```

###  Alternatives

[zerkalica/semaphore

This library provides an api for semaphore acquire and release

1119.0k1](/packages/zerkalica-semaphore)[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)
