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

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

cevin/lock
==========

php open lock

v1.0(6y ago)14MITPHP

Since Aug 11Pushed 6y ago1 watchersCompare

[ Source](https://github.com/cevin/lock)[ Packagist](https://packagist.org/packages/cevin/lock)[ RSS](/packages/cevin-lock/feed)WikiDiscussions master Synced 4d ago

READMEChangelogDependenciesVersions (2)Used By (0)

A Simple &amp; Open lock driver for php
=======================================

[](#a-simple--open-lock-driver-for-php)

usage
-----

[](#usage)

```
require __DIR__.'/vendor/autoload.php';

$driver = new Cevin\Lock\Driver\Redis('localhost');
$lock = new Cevin\Lock\Lock($driver);

$lockKey = sprintf('goods:%d',1);
$userId = 1;
$lockExpire = 10;
$waitSecondsForGetingLock = 10;

$status = $lock->waitLock($lockKey,$userId,$lockExpire,$waitSecondsForGetingLock);

sleep(5);// another processor status will be waiting
# sleep(11); // current lock will be expired
# sleep(11); // lock fail, $status=false

$lock->unlock($lockKey);

if ($lock->waitLock($lockKey,$uid,10,5))
{
    // do something
    $lock->unlock($lockKey);
}
```

custom driver
-------------

[](#custom-driver)

```
class dbDriver implements Driver
{
    public function tryGetLock($name, $content, $expire)
    {
        if(DB::select('exists lock'))
            return false;
        else
            return DB::query('insert...');

    }

    public function unlock($name)
    {
        return DB::from('lock')->where('pk',$name)->delete();
    }

    public function viewLock($name)
    {
        return DB::select('content')->from('lock')->where('pk',$name)->value();
    }
}
$lock = new Lock(new dbDriver());
```

###  Health Score

25

—

LowBetter than 37% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity5

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity58

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

2469d ago

### Community

Maintainers

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

---

Top Contributors

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

### Embed Badge

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

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

###  Alternatives

[codewithdennis/filament-simple-alert

A plugin for adding straightforward alerts to your filament pages

123208.5k3](/packages/codewithdennis-filament-simple-alert)

PHPackages © 2026

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