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

ActiveLibrary

fwhappy/lock
============

Lock

v1.0.0(9y ago)1221PHPPHP &gt;=5.3.0

Since May 16Pushed 9y ago1 watchersCompare

[ Source](https://github.com/fwhappy/lock)[ Packagist](https://packagist.org/packages/fwhappy/lock)[ RSS](/packages/fwhappy-lock/feed)WikiDiscussions master Synced 2mo ago

READMEChangelog (1)DependenciesVersions (2)Used By (0)

lock
====

[](#lock)

概述
--

[](#概述)

- Lock包使用Redis来实现并发锁功能
- 支持设置超时时间
- 支持锁过期时间

使用
--

[](#使用)

1、安装扩展

- 支持composer安装

    ```
      {
        "require": {
          "php": ">=5.3.0",
          "fwhappy/lock": "^1.0"
        },
        "repositories": {
          "packagist": {
            "type": "composer",
            "url": "https://packagist.org"
          }
        }
      }

    ```
- 或者

    ```
      composer require fwhappy/lock ^1.0

    ```
- 也可以直接clone，放到项目中

    ```
      git clone git@github.com:fwhappy/lock.git

    ```

2、使用示例

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

use Camry\Lock\Lock as Lock;

$redis = new Redis();
$redis->connect("127.0.0.1", 7480);
$redis->select(7);

$lock = new Lock($redis);
echo str_pad(" ", 4096);

if ($lock->acquire("TEST:LOCK:KEY", 10)) {
    echo "操作成功" . time();
    sleep(5);
    $lock->release("TEST:LOCK:KEY");
} else {
    echo "操作失败" . time();
}

```

###  Health Score

26

—

LowBetter than 43% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity9

Limited adoption so far

Community8

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

3285d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/90354138547663e9f2ec4e567be03af2405ce282983ed594bac3def293bd0540?d=identicon)[fwhappy](/maintainers/fwhappy)

---

Top Contributors

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

### Embed Badge

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

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

PHPackages © 2026

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