New

Just launched: Vueblocks, a brand-new search engine for Vue packages! Explore Vueblocks →

ginnerpeace/laravel-redis-lock

Simple redis distributed locks for Laravel.
127,542 15

Larablocks Analysis

ginnerpeace/laravel-redis-lock works with Laravel 5 to 11 (latest release v2.4.2, Nov 18, 2024), all past end of life (the last on Mar 12, 2026): no more fixes, even for security.

Recommendation checks

Not advised

Not advised: no release or commit in over 2 years.

  • No release or commit in over 2 years
  • Supports only Laravel 5 to 11, past end of life since Mar 12, 2026
  • No release in the last 12 months (last: Nov 18, 2024)
  • 1,281 downloads a month (needs 10,000)
  • 15 GitHub stars (needs 100)

State

Likely abandoned
  • No release or commit in over 2 years.
  • Last stable release: Nov 18, 2024.
  • No releases in the last 12 months.
  • First released: Jun 30, 2019.
  • Monthly downloads: 1,281, down 14% from six months ago.
  • 0 open issues on GitHub.

Data from Packagist and GitHub, checked by Larablocks on Dec 1, 2026.

Install
composer require ginnerpeace/laravel-redis-lock
Latest Version:v2.4.2
PHP:^7.0|^8.0
Laravel:5 – 11
License:MIT
Last Updated:Nov 18, 2024
Links: GitHub  ·  Packagist
Maintainer: jay-youngn

laravel-redis-lock

Total Downloads Latest Stable Version Latest Unstable Version License

Simple redis distributed locks for Laravel.

Getting started

Install

Using composer.

composer require "ginnerpeace/laravel-redis-lock:~2.3"

Add service provider:

Normally.

<?php
return [
    // ....
    'providers' => [
        // ...
        RedisLock\Providers\RedisLockServiceProvider::class,
    ],
    // Its optional.
    'aliases' => [
        // ...
        'RedisLock' => RedisLock\Facades\RedisLock::class,
    ],
    // ...
];

After Laravel 5.5, the package auto-discovery is supported.

{
    "providers": [
        "RedisLock\\Providers\\RedisLockServiceProvider"
    ],
    "aliases": {
        "RedisLock": "RedisLock\\Facades\\RedisLock"
    }
}

Lumen

$app->register(RedisLock\Providers\LumenRedisLockServiceProvider::class);

Publish resources (laravel only)

Copied config to config/redislock.php.

php artisan vendor:publish --provider="RedisLock\Providers\RedisLockServiceProvider"

Default items:

<?php

return [
    // Use app('redis')->connection('default')
    'connection' => 'default',
    'retry_count' => 3,
    'retry_delay' => 200,
];

Use

<?php

use RedisLock\Facades\RedisLock;

// Set the specified expire time, in milliseconds.
$millisecond = 100000;

// Try get lock.
// If has non-null property `$this->retryCount`, will retry some times with its value.
// Default value is `config('redislock.retry_count')`
$payload = RedisLock::lock('key', $millisecond);
/*
[
    "key" => "key",
    "token" => "21456004925bd1532e64616",
    "expire" => 100000,
    "expire_type" => "PX",
]
*/

// If cannot get lock, will return empty array.
$payload = RedisLock::lock('key', 100000);
/*
[]
*/

// Return bool.
RedisLock::unlock($payload);

// Determine a lock if it still effective.
RedisLock::verify($payload);

// Reset a lock if it still effective.
// The returned value is same to use RedisLock::lock()
RedisLock::relock($payload, $millisecond);

/////////////////////
// Special usages: //
/////////////////////

// Retry 5 times when missing the first time.
// Non-null `$retry` param will priority over `$this->retryCount`.
RedisLock::lock('key', 100000, 5);

// No retry (Try once only).
RedisLock::lock('key', 100000, 0);
// If value less than 0, still means try once only.
// RedisLock::lock('key', 100000, -1);
// Hmmmmmmm...Not pretty.

// Change property `$this->retryDelay` (Default value is `config('redislock.retry_delay')`).
// Retry 10 times when missing the first time.
// Every retry be apart 500 ~ 1000 milliseconds.
RedisLock::setRetryDelay(1000)->lock('key', 100000, 10);
// PS:
// RedisLock is default registered to singleton, call method `setRetryDelay()` will affects subsequent code.

// Use in business logic:
try {
    if (! $lock = RedisLock::lock('do-some-thing', 100000)) {
        throw new Exception('Resource locked.');
    }
    //////////////////////
    // Call ur methods. //
    //////////////////////
} catch (Exception $e) {
    throw $e;
} finally {
    RedisLock::unlock($lock);
}

Related Packages

liugj/lumen-redis-provider

lumen redis Provider

307 0
monospice/laravel-redis-sentinel-drivers

Redis Sentinel integration for Laravel and Lumen.

854,784 104
arungowda325/laravel-redis-sentinel-connection

Redis Sentinel connection for Laravel and Lumen.

75 0
ifeltsweet/laravel-redis

Adds support for PhpRedis to Laravel and Lumen 4.x/5.x

7 0
nnjeim/persist

Laravel cache helper methods

60 1

Version History

Version Released PHP Laravel License
v2.4.2 ^7.0|^8.0 ^5.1|^6.0|^7.0|^8.0|^9.0|^10.0|^11.0 MIT
v2.4.1 ^7.0|^8.0 ^5.1|^6.0|^7.0|^8.0|^9.0|^10.0 MIT
v2.4.0 ^7.0|^8.0 ^5.1|^6.0|^7.0|^8.0|^9.0 MIT
v2.3.3 ^7.0|^8.0 ^5.1|^6.0|^7.0|^8.0|^9.0 MIT
v2.3.2 ^7.0|^8.0 ^5.1|^6.0|^7.0|^8.0 MIT