PHPackages                             ignashevroman/laravel-redis-sentinel-retry - 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. ignashevroman/laravel-redis-sentinel-retry

ActiveLibrary[Caching](/categories/caching)

ignashevroman/laravel-redis-sentinel-retry
==========================================

Redis Sentinel connector for Laravel with runtime failover and retry support.

1.0.0(1y ago)5593↓50%[3 PRs](https://github.com/ignashevroman/laravel-redis-sentinel-retry/pulls)MITPHPPHP ^8.1CI passing

Since Apr 25Pushed 4mo ago2 watchersCompare

[ Source](https://github.com/ignashevroman/laravel-redis-sentinel-retry)[ Packagist](https://packagist.org/packages/ignashevroman/laravel-redis-sentinel-retry)[ Docs](https://github.com/ignashevroman/laravel-redis-sentinel-retry)[ RSS](/packages/ignashevroman-laravel-redis-sentinel-retry/feed)WikiDiscussions main Synced 1mo ago

READMEChangelog (1)Dependencies (5)Versions (5)Used By (0)

Laravel Redis Sentinel Retry
============================

[](#laravel-redis-sentinel-retry)

[![Latest Stable Version](https://camo.githubusercontent.com/f35aedeaa4da8e0514f3a0e731d4e4f16321e56e315f08fb3e5513c745d277b2/687474703a2f2f706f7365722e707567782e6f72672f69676e6173686576726f6d616e2f6c61726176656c2d72656469732d73656e74696e656c2d72657472792f76)](https://packagist.org/packages/ignashevroman/laravel-redis-sentinel-retry)[![Total Downloads](https://camo.githubusercontent.com/d7cae4f2709116ded49e7ab13aea21104ab94c03083261e8c8a772b1016e7cca/687474703a2f2f706f7365722e707567782e6f72672f69676e6173686576726f6d616e2f6c61726176656c2d72656469732d73656e74696e656c2d72657472792f646f776e6c6f616473)](https://packagist.org/packages/ignashevroman/laravel-redis-sentinel-retry)[![License](https://camo.githubusercontent.com/bb6aa6ede0a89424f8e8f87530e3272f57a2b7160e3b7bf2f10ce300936ecbc2/687474703a2f2f706f7365722e707567782e6f72672f69676e6173686576726f6d616e2f6c61726176656c2d72656469732d73656e74696e656c2d72657472792f6c6963656e7365)](https://packagist.org/packages/ignashevroman/laravel-redis-sentinel-retry)[![PHP Version Require](https://camo.githubusercontent.com/9baa08324c0de598bd7a06a9b83d41d381673f6b6a0fb05a02722b24b9a3caea/687474703a2f2f706f7365722e707567782e6f72672f69676e6173686576726f6d616e2f6c61726176656c2d72656469732d73656e74696e656c2d72657472792f726571756972652f706870)](https://packagist.org/packages/ignashevroman/laravel-redis-sentinel-retry)[![Tests](https://github.com/ignashevroman/laravel-redis-sentinel-retry/workflows/Tests/badge.svg)](https://github.com/ignashevroman/laravel-redis-sentinel-retry/actions?query=workflow%3ATests)[![Quality Gate Status](https://camo.githubusercontent.com/4313dc1f65ff1ff4f6b121b8b3c27f16b2c7afa87b8835105f3f3f84ae35d34e/68747470733a2f2f736f6e6172636c6f75642e696f2f6170692f70726f6a6563745f6261646765732f6d6561737572653f70726f6a6563743d69676e6173686576726f6d616e5f6c61726176656c2d72656469732d73656e74696e656c2d7265747279266d65747269633d616c6572745f737461747573)](https://sonarcloud.io/dashboard?id=ignashevroman_laravel-redis-sentinel-retry)[![Maintainability Rating](https://camo.githubusercontent.com/deff6fee83b0909f4a96dbc9e9d6b041635f451b384124301a2de368c2a2f501/68747470733a2f2f736f6e6172636c6f75642e696f2f6170692f70726f6a6563745f6261646765732f6d6561737572653f70726f6a6563743d69676e6173686576726f6d616e5f6c61726176656c2d72656469732d73656e74696e656c2d7265747279266d65747269633d7371616c655f726174696e67)](https://sonarcloud.io/dashboard?id=ignashevroman_laravel-redis-sentinel-retry)[![Reliability Rating](https://camo.githubusercontent.com/5d6b1dba59654905f6e0e21be889a3054e2de1634815d2d1022587cae09f0bd2/68747470733a2f2f736f6e6172636c6f75642e696f2f6170692f70726f6a6563745f6261646765732f6d6561737572653f70726f6a6563743d69676e6173686576726f6d616e5f6c61726176656c2d72656469732d73656e74696e656c2d7265747279266d65747269633d72656c696162696c6974795f726174696e67)](https://sonarcloud.io/dashboard?id=ignashevroman_laravel-redis-sentinel-retry)[![Security Rating](https://camo.githubusercontent.com/c49bbd8ddd1aaeec7b9d7e89699079c2013f0ad888bc2d65884231c6ac9acfef/68747470733a2f2f736f6e6172636c6f75642e696f2f6170692f70726f6a6563745f6261646765732f6d6561737572653f70726f6a6563743d69676e6173686576726f6d616e5f6c61726176656c2d72656469732d73656e74696e656c2d7265747279266d65747269633d73656375726974795f726174696e67)](https://sonarcloud.io/dashboard?id=ignashevroman_laravel-redis-sentinel-retry)[![Vulnerabilities](https://camo.githubusercontent.com/162b72720637a9c841ae7dde23e44e5c896f33cf1625b29897b8ce79e3bc76d7/68747470733a2f2f736f6e6172636c6f75642e696f2f6170692f70726f6a6563745f6261646765732f6d6561737572653f70726f6a6563743d69676e6173686576726f6d616e5f6c61726176656c2d72656469732d73656e74696e656c2d7265747279266d65747269633d76756c6e65726162696c6974696573)](https://sonarcloud.io/dashboard?id=ignashevroman_laravel-redis-sentinel-retry)[![codecov](https://camo.githubusercontent.com/84472670e4b0ab767c6d6b5ac5781eb510dff0c0ff819481e4d85c805bfb7506/68747470733a2f2f636f6465636f762e696f2f67682f69676e6173686576726f6d616e2f6c61726176656c2d72656469732d73656e74696e656c2d72657472792f6272616e63682f6d61696e2f67726170682f62616467652e7376673f746f6b656e3d5a334441535a4744364d)](https://codecov.io/gh/ignashevroman/laravel-redis-sentinel-retry)

Overview
--------

[](#overview)

This package extends the standard Redis integration in Laravel, enabling it to work with Redis Sentinel while providing automatic failover handling and retry logic for transient errors.

It is based on the [Namoshek/laravel-redis-sentinel](https://github.com/Namoshek/laravel-redis-sentinel) package, with enhancements for retries and failover handling.

### Features:

[](#features)

- Connects to Redis through Sentinel.
- Retries on connection failure and failover.
- Uses `PhpRedis` extension for Redis connections.
- Simple configuration with Laravel built-in Redis system.

### Comparison with `namoshek/laravel-redis-sentinel`

[](#comparison-with-namosheklaravel-redis-sentinel)

Feature`ignashevroman/laravel-redis-sentinel-retry``namoshek/laravel-redis-sentinel`Connection via Redis Sentinel✅✅Easy integration✅✅Automatic retry on connection failures✅❌Failover during runtime✅❌Configurable retry attempts and delays✅❌Focus on production stability✅❌Error handling strategyCatch and retryImmediate exceptionInstallation
------------

[](#installation)

Install the package via Composer:

```
composer require ignashevroman/laravel-redis-sentinel-retry
```

Configuration
-------------

[](#configuration)

In your `config/database.php`, add a new connection entry under the `redis` array, which uses the `phpredis-sentinel` client.

```
'redis' => [
    'client' => env('REDIS_CLIENT', 'phpredis-sentinel'),

    'default' => [
        'sentinel_host' => env('REDIS_SENTINEL_HOST', '127.0.0.1'),
        'sentinel_port' => (int) env('REDIS_SENTINEL_PORT', 26379),
        'sentinel_service' => env('REDIS_SENTINEL_SERVICE', 'mymaster'),
        'sentinel_timeout' => (float) env('REDIS_SENTINEL_TIMEOUT', 0),
        'sentinel_persistent' => env('REDIS_SENTINEL_PERSISTENT'),
        'sentinel_retry_interval' => (int) env('REDIS_SENTINEL_RETRY_INTERVAL', 0),
        'sentinel_read_timeout' => (float) env('REDIS_SENTINEL_READ_TIMEOUT', 0),
        'sentinel_username' => env('REDIS_SENTINEL_USERNAME'),
        'sentinel_password' => env('REDIS_SENTINEL_PASSWORD'),
        'password' => env('REDIS_PASSWORD'),
        'database' => (int) env('REDIS_DB', 0),

        // Additional options for retry functionality
        'sentinel_max_retries' => env('REDIS_SENTINEL_MAX_RETRIES', 3),
        'sentinel_retry_delay' => env('REDIS_SENTINEL_RETRY_DELAY', 100_000),
    ]
],
```

> **Note:** The configuration options are the same as in [namoshek/laravel-redis-sentinel](https://github.com/Namoshek/laravel-redis-sentinel), with two additional options for retry functionality:

- `sentinel_max_retries`: The number of retry attempts for Redis operations (default: 3).
- `sentinel_retry_delay`: The delay between retries in microseconds (default: 100,000).

Differences in Implementation:
------------------------------

[](#differences-in-implementation)

1. **Retry Logic (Retries)**

    - This implementation introduces **retry logic** to handle transient errors such as **temporary connection failures** or **readonly states**. This allows automatic retries of requests if Redis becomes operational again after a failure.
    - In the case of an error like "READONLY" or a connection loss, the client will automatically retry the connection multiple times, improving the system's resilience.
2. **Integration with Redis Sentinel:**

    - This implementation enhances the **automatic failover mechanism** with Redis Sentinel. When the primary Redis server fails, the system automatically switches to a new master, if possible.
    - The **new master** is selected via **Redis Sentinel**, and if the current client loses connection or becomes "readonly", it tries to reconnect to the new master, taking into account settings for **retry attempts and delays**.
3. **Configuration Parameters:**

    - Two new configuration parameters were added to this package:
        - `sentinel_max_retries` — the maximum number of reconnection attempts.
        - `sentinel_retry_delay` — the delay between reconnection attempts.
    - These parameters provide flexibility in configuring the number of retries and delays for reconnection in case of failures.
4. **RedisWrapper Reconnection Logic:**

    - The **RedisWrapper** class manages the Redis client and encapsulates the retry logic, error checking, and failover handling.
    - If the connection is lost or becomes readonly, RedisWrapper automatically retries the connection for a set number of attempts, improving Redis availability.
5. **Error Handling in RedisWrapper:**

    - When an error occurs, such as a lost connection or readonly error, RedisWrapper attempts to **reconnect** through **handleFailover** (a method that manages reconnection).
    - If Redis does not recover after several attempts, an exception is thrown, just like in a standard Redis error scenario.

In general, this implementation focuses on improving fault tolerance and automating Redis connection management with Redis Sentinel, along with additional settings for controlling retry attempts and delay between reconnections.

License
-------

[](#license)

This package is licensed under the MIT License. See the [LICENSE](LICENSE.md) file for more information.

Acknowledgments
---------------

[](#acknowledgments)

A special thanks to the Namoshek team for their excellent work on the original [laravel-redis-sentinel](https://github.com/Namoshek/laravel-redis-sentinel) package, which served as the foundation for this package. This package extends their work by adding automatic retry functionality for Redis operations during failover scenarios.

###  Health Score

39

—

LowBetter than 86% of packages

Maintenance62

Regular maintenance activity

Popularity21

Limited adoption so far

Community15

Small or concentrated contributor base

Maturity49

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 63.4% 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

382d ago

### Community

Maintainers

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

---

Top Contributors

[![Namoshek](https://avatars.githubusercontent.com/u/8877609?v=4)](https://github.com/Namoshek "Namoshek (52 commits)")[![ignashevroman](https://avatars.githubusercontent.com/u/47656668?v=4)](https://github.com/ignashevroman "ignashevroman (23 commits)")[![dependabot[bot]](https://avatars.githubusercontent.com/in/29110?v=4)](https://github.com/dependabot[bot] "dependabot[bot] (2 commits)")[![misakstvanu](https://avatars.githubusercontent.com/u/42741294?v=4)](https://github.com/misakstvanu "misakstvanu (1 commits)")[![Alhubing](https://avatars.githubusercontent.com/u/16296784?v=4)](https://github.com/Alhubing "Alhubing (1 commits)")[![OrangeJuiced](https://avatars.githubusercontent.com/u/22561290?v=4)](https://github.com/OrangeJuiced "OrangeJuiced (1 commits)")[![igoooor](https://avatars.githubusercontent.com/u/1036285?v=4)](https://github.com/igoooor "igoooor (1 commits)")[![miladev95](https://avatars.githubusercontent.com/u/35612406?v=4)](https://github.com/miladev95 "miladev95 (1 commits)")

---

Tags

laravelredisretrysentinelfailover

###  Code Quality

Code StylePHP CS Fixer

### Embed Badge

![Health badge](/badges/ignashevroman-laravel-redis-sentinel-retry/health.svg)

```
[![Health](https://phpackages.com/badges/ignashevroman-laravel-redis-sentinel-retry/health.svg)](https://phpackages.com/packages/ignashevroman-laravel-redis-sentinel-retry)
```

###  Alternatives

[monospice/laravel-redis-sentinel-drivers

Redis Sentinel integration for Laravel and Lumen.

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

An extension of Laravels Redis driver which supports connecting to a Redis master through Redis Sentinel.

38679.0k](/packages/namoshek-laravel-redis-sentinel)[yangusik/laravel-balanced-queue

Laravel queue management with load balancing between partitions (user groups)

786.4k](/packages/yangusik-laravel-balanced-queue)[encore/redis-manager

Redis manager for laravel

25243.1k](/packages/encore-redis-manager)[vetruvet/laravel-phpredis

Use phpredis as the redis connection in Laravel

43123.7k](/packages/vetruvet-laravel-phpredis)[dragon-code/laravel-cache

An improved interface for working with cache

6844.8k10](/packages/dragon-code-laravel-cache)

PHPackages © 2026

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