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

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

agboon/yii2-redis-ha
====================

Basic redis-ha client

1.5.1(3y ago)011.6k↓50%BSD-3-ClausePHP

Since Jan 10Pushed 3y agoCompare

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

READMEChangelog (4)Dependencies (1)Versions (5)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

28

—

LowBetter than 54% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity23

Limited adoption so far

Community9

Small or concentrated contributor base

Maturity49

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 87% 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 ~2 days

Total

3

Last Release

1212d ago

### Community

Maintainers

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

---

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)")[![agboon](https://avatars.githubusercontent.com/u/18414214?v=4)](https://github.com/agboon "agboon (1 commits)")

---

Tags

redisyii2sentinel

### Embed Badge

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

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

###  Alternatives

[pyurin/yii2-redis-ha

Basic redis-ha client

18272.7k](/packages/pyurin-yii2-redis-ha)[monospice/laravel-redis-sentinel-drivers

Redis Sentinel integration for Laravel and Lumen.

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

PHPackages © 2026

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