PHPackages                             quhang/redis-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. [Caching](/categories/caching)
4. /
5. quhang/redis-lock

ActiveLibrary[Caching](/categories/caching)

quhang/redis-lock
=================

use redis to control concurrent.

0.0.8(8y ago)1434MITPHP

Since Mar 7Pushed 8y ago1 watchersCompare

[ Source](https://github.com/zm-john/redis-lock)[ Packagist](https://packagist.org/packages/quhang/redis-lock)[ RSS](/packages/quhang-redis-lock/feed)WikiDiscussions master Synced 3w ago

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

Redis Lock
==========

[](#redis-lock)

> Use redis feature to implement lock. I use this to control concurrent.

Laravel
-------

[](#laravel)

### laravel 5.5+

[](#laravel-55)

you can publish config, then set redis connection in .env `REDIS_LOCK_CONNECTION`.

```
php artisan vendor:publish

```

### laravel 5.1 ~ 5.4

[](#laravel-51--54)

if you want to config your webhook, you need add `Quhang\RedisLock\Laravel\ServiceProvider` to `config/app.php`

```
'providers' => [
    // ...
    Quhang\RedisLock\Laravel\ServiceProvider::class,
    // ...
]

```

add `Quhang\RedisLock\Laravel\Facades\Lock` to `config/app.php`

```
'aliases' => [
    // ...
    'Lock' => Quhang\RedisLock\Laravel\Facades\Lock::class,
    // ...
]

```

### usage

[](#usage)

#### `get` method will return true or false.

[](#get-method-will-return-true-or-false)

```
    try {
        $rest = \Quhang\RedisLock\Laravel\Facades\Lock::get($key);
        if ($rest) {
            // get lock success
        } else {
            // get lock fail
        }
    } finally {
        \Quhang\RedisLock\Laravel\Facades\Lock::release($key);
    }

```

#### `tryToGet` method will be block until get lock or timeout.

[](#trytoget-method-will-be-block-until-get-lock-or-timeout)

```
    try {
        \Quhang\RedisLock\Laravel\Facades\Lock::tryToGet($key, $timeout = 10);
    } catch (Quhang\RedisLock\TimeoutException $e) {
        // timeout exception
    } finally {
        \Quhang\RedisLock\Laravel\Facades\Lock::release($key);
    }

```

Other
-----

[](#other)

```
$client = new \Predis\Client($config, $option);
$lock = new \Quhang\RedisLock\Lock($client);

// try to get lock for key once
try {
    $lock->get($key);
    // your logic
} finally {
    $lock->release($key);
}

######################################################

// try to get lock for key many times untill timeout
try {
    $lock->tryToGet($key, $timeout = 10);
    // your logic
} catch(\Quhang\RedisLock\TimeoutException $e) {
    // timeout handle
} finally {
    $lock->release($key);
}

```

license
-------

[](#license)

MIT

###  Health Score

27

—

LowBetter than 47% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity14

Limited adoption so far

Community4

Small or concentrated contributor base

Maturity58

Maturing project, gaining track record

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

Every ~2 days

Total

8

Last Release

3025d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/3333203?v=4)[quhang](/maintainers/quhang)[@quhang](https://github.com/quhang)

---

Tags

redislock

### Embed Badge

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

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

###  Alternatives

[rhubarbgroup/redis-cache

A persistent object cache backend for WordPress powered by Redis. Supports Predis, PhpRedis, Relay, replication, sentinels, clustering and WP-CLI.

527101.4k1](/packages/rhubarbgroup-redis-cache)[symfony-bundles/redis-bundle

Symfony Redis Bundle

291.2M7](/packages/symfony-bundles-redis-bundle)[pdffiller/qless-php

PHP Bindings for qless

29113.7k2](/packages/pdffiller-qless-php)[icecave/chastity

Distributed advisory locking for PHP.

1513.3k](/packages/icecave-chastity)[avtonom/semaphore-bundle

A generic locking Symfony bundle for PHP, that uses named locks for semaphore acquire and release, to guarantee atomicity

112.9k](/packages/avtonom-semaphore-bundle)

PHPackages © 2026

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