PHPackages                             pyurin/yii2-redis-ha - 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. pyurin/yii2-redis-ha

ActiveYii2-extension[Caching](/categories/caching)

pyurin/yii2-redis-ha
====================

Basic redis-ha client

1.2(8y ago)18289.9k↓59.9%13BSD-3-ClausePHP

Since Mar 1Pushed 3y ago3 watchersCompare

[ Source](https://github.com/pyurin/yii2-redis-ha)[ Packagist](https://packagist.org/packages/pyurin/yii2-redis-ha)[ RSS](/packages/pyurin-yii2-redis-ha/feed)WikiDiscussions master Synced 3d ago

READMEChangelog (4)Dependencies (1)Versions (7)Used By (0)

Client for redis Highly Available set for Yii2
==============================================

[](#client-for-redis-highly-available-set-for-yii2)

This Yii2 component is based on core yii2-redis component  but gives ability to work with master-slave redis clusters with sentiels.
It's rather simple - gets master server address from given sentinels and connects to it, then operates just like \\yii\\redis\\Connection.
It works with sentinels only, does not connect to redis hosts without sentinels.

Workflow of connection process
------------------------------

[](#workflow-of-connection-process)

Loop over given sentinels and search for an alive one that will give a master host address.
If a sentinel does not respond or it's respond is empty, then we'll try to check the next one.
If no successfull reply was received, then connection will fail.
After we've found a redis master, we'll connect to it.
If connection to the master server fails, we won't try anything else, we'll fail.
If we sucessfully connect to the master server, we'll then check with `role` command if it really is master ().
If it's not - we'll fail, if it really is - we're sucessfully connected.

Adviced configuration
---------------------

[](#adviced-configuration)

Redis HA cluster must be done with minimum 2 redis servers and 3 sentinels.
I suppose that in termes of performance, considering this implementation it's better to have a sentinel server for each app locally, to avoid unnecessary overheads.
That would not be important if we cached previously givem master server, but we dont. We ask sentinel each time before connecting to redis.
That's how I see a simple architecture:

```
    -------                    -------
   |       |                  |       |
   | Redis |                  | Redis |
   |       |                  |       |
    ------- \                 /-------
       |     \               /   |
       |      \             /    |
       |       \-----------/     |
       |       |\         /|     |
       |       |  Sentinel |     |
       |       |   .    .  |     |
       |        --.------.-      |
       |         .        .      |
       |        .          .     |
  -----|-------.---        -.----|----------
 |     |      .    |      |  .   |          |
 |    Sentinel. . .| . . .|. . Sentinel     |
 |         |       |      |         |       |
 |  (localhost)    |      |  (localhost)    |
 |         |       |      |         |       |
 |         |       |      |         |       |
 |        APP      |      |        APP      |
 |                 |      |                 |
  -----------------        -----------------

```

Usage
-----

[](#usage)

Basic example:

```
  			'session' => [
  					'class' => '\yii\redis\Session',
  					'redis' => [
  						'class' => '\pyurin\yii\redisHa\Connection',
  						'masterName' => 'mymaster',
  						'sentinels' => [
  								'localhost'
  						]
  					]
  			],

```

Sentinel servers are queried in the same order as exist in array.

Installation
============

[](#installation)

Available with composer:

```
  "require" : {
    "pyurin/yii2-redis-ha":"*"
  },

```

###  Health Score

41

—

FairBetter than 87% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity45

Moderate usage in the ecosystem

Community14

Small or concentrated contributor base

Maturity67

Established project with proven stability

 Bus Factor1

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

Every ~197 days

Recently: every ~246 days

Total

6

Last Release

3154d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/839a3915796a997c92d4f2e32ae8b553ade2e4a0481454e3662dfff32e9bc2a9?d=identicon)[pyurin](/maintainers/pyurin)

---

Top Contributors

[![pyurin](https://avatars.githubusercontent.com/u/6748033?v=4)](https://github.com/pyurin "pyurin (20 commits)")[![zukk](https://avatars.githubusercontent.com/u/3678447?v=4)](https://github.com/zukk "zukk (2 commits)")

---

Tags

redisyii2sentinel

### Embed Badge

![Health badge](/badges/pyurin-yii2-redis-ha/health.svg)

```
[![Health](https://phpackages.com/badges/pyurin-yii2-redis-ha/health.svg)](https://phpackages.com/packages/pyurin-yii2-redis-ha)
```

###  Alternatives

[monospice/laravel-redis-sentinel-drivers

Redis Sentinel integration for Laravel and Lumen.

103843.6k](/packages/monospice-laravel-redis-sentinel-drivers)

PHPackages © 2026

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