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)14341MITPHP

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 4d 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

28

—

LowBetter than 54% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity15

Limited adoption so far

Community5

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

2976d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/d7212490383fc09e674399152a2cadec6c293a182a64c1d97889e630dd20331d?d=identicon)[quhang](/maintainers/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

[predis/predis-async

Asynchronous version of Predis

366348.4k](/packages/predis-predis-async)[rhubarbgroup/redis-cache

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

51795.3k1](/packages/rhubarbgroup-redis-cache)[monospice/laravel-redis-sentinel-drivers

Redis Sentinel integration for Laravel and Lumen.

103830.5k](/packages/monospice-laravel-redis-sentinel-drivers)[jamescauwelier/psredis

Sentinel client for the popular php redis client

77392.9k5](/packages/jamescauwelier-psredis)[cache/predis-adapter

A PSR-6 cache implementation using Redis (Predis). This implementation supports tags

272.6M13](/packages/cache-predis-adapter)[symfony-bundles/redis-bundle

Symfony Redis Bundle

271.1M5](/packages/symfony-bundles-redis-bundle)

PHPackages © 2026

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