PHPackages                             shibo/redis - 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. shibo/redis

ActiveLibrary[Caching](/categories/caching)

shibo/redis
===========

1.1.2(8y ago)141123MITPHP

Since Mar 9Pushed 8y ago3 watchersCompare

[ Source](https://github.com/qishibo/redis)[ Packagist](https://packagist.org/packages/shibo/redis)[ RSS](/packages/shibo-redis/feed)WikiDiscussions master Synced 3w ago

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

PHP Redis
=========

[](#php-redis)

Redis client for php, which supports single redis server, or redis Master-Slave clusters.

Install
-------

[](#install)

1.**composer is recommended**

`composer require shibo/redis`

or in your `composer.json`

```
{
    "require": {
        "shibo/redis" : "^1.0"
    }
}
```

2.**if you do not use composer, you should `include 'Autoload.php'` in your code**

Example
-------

[](#example)

1.**single redis server**

read &amp; write operations are all executed in the single serve.

```
use \Redis\SingleClient;
use \Redis\Drivers\RedisFactory;

include 'Autoload.php';

$config = ['host' => '127.0.0.1', 'port' => 6379, 'weight' => 1];

// if need auth
// $config = ['host' => '127.0.0.1', 'port' => 6379, 'weight' => 1, 'auth' => 'qii'];

$redis = new SingleClient(
    $config,
    RedisFactory::PHPREDIS // this is optional param, default is PHPREDIS driver
);

$redis->set('name', 'qii404'); // true
$redis->get('name'); // 'qii404'
```

2.**redis cluster without slaves**

read &amp; write operations executed in the same one server of the cluster.

```
use Redis\Drivers\RedisFactory;
use Redis\WithoutSlavesClient;
use Redis\Hash;
use Redis\Key;

include 'Autoload.php';

$config = [
    ['host' => '127.0.0.1', 'port' => 6379, 'weight' => 1],
    ['host' => '127.0.0.1', 'port' => 6380],
];

// hash stragety, you can also define your stragety in Hash folder
$hash = new Hash\Consistant();

// key hasher, such as new Md5 or Cr32, you can add it in Key folder
$calculator = new Key\Cr32();
// $calculator = new Key\Md5();

$redis = new WithoutSlavesClient(
    $config,
    $hash,
    $calculator,
    RedisFactory::PHPREDIS // this is optional param, default is PHPREDIS driver
);

// when using the same key, both read & write operation executed in the same server, such as port 6379
$redis->hset('profile', 'name', 'qii44'); // true
$redis->hget('profile', 'name'); // 'qii404'
```

3.**redis cluster with slaves**

read &amp; write operations executed in the different servers, read from the slave servers, write from the master servers

(*You should config it right for 'm' &amp; 's', such as 6381 is slave of 6379, 6382 is slave of 6380*).

```
use Redis\Drivers\RedisFactory;
use Redis\WithSlavesClient;
use Redis\Hash;
use Redis\Key;

include 'Autoload.php';

$config = [
    'm' =>[
        ['host' => '127.0.0.1', 'port' => 6379, 'weight' => 1],
        ['host' => '127.0.0.1', 'port' => 6380],
    ],
    's' =>[
        ['host' => '127.0.0.1', 'port' => 6381],
        ['host' => '127.0.0.1', 'port' => 6382],
    ]
];

// hash stragety, you can also define your stragety in Hash folder
$hash = new Hash\Consistant();

// key hasher, such as new Md5 or Cr32, you can add it in Key folder
$calculator = new Key\Cr32();
// $calculator = new Key\Md5();

$redis = new WithSlavesClient(
    $config,
    $hash,
    $calculator,
    RedisFactory::PHPREDIS // this is optional param, default is PHPREDIS driver
);

$redis->zadd('key', 99, 'qii404'); // true; executes in master server, such as port 6379
$redis->zscore('key', 'qii404'); // 99; executes in slave server, such as port 6381
```

Attentions
----------

[](#attentions)

- When you use the 'weight' in the config, it works only in the cluster mode, and when in the Master-Slave mode, you should config in the 'm' arrays but not 's' arrays.
- The different clients are implemented by polymorphism, so it is simple and efficient, but you need to new a client yourself.
- If you have any questions, do not ask me.

###  Health Score

33

—

LowBetter than 72% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity19

Limited adoption so far

Community12

Small or concentrated contributor base

Maturity67

Established project with proven stability

 Bus Factor1

Top contributor holds 95.3% 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 ~239 days

Total

4

Last Release

3038d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/3348c6c4cc0f4242bf0e55ae2ebe4a8a421ed0a8da272712df8773862fa9c15e?d=identicon)[qishibo](/maintainers/qishibo)

---

Top Contributors

[![qishibo](https://avatars.githubusercontent.com/u/5136418?v=4)](https://github.com/qishibo "qishibo (41 commits)")[![qii404](https://avatars.githubusercontent.com/u/19650143?v=4)](https://github.com/qii404 "qii404 (2 commits)")

### Embed Badge

![Health badge](/badges/shibo-redis/health.svg)

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

###  Alternatives

[barryvdh/laravel-httpcache

HttpCache for Laravel

502404.4k10](/packages/barryvdh-laravel-httpcache)

PHPackages © 2026

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