PHPackages                             zkc/yii2-predis - 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. zkc/yii2-predis

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

zkc/yii2-predis
===============

Redis Cache, Session for the Yii2

1.0.1(9mo ago)00MITPHP

Since May 7Pushed 9mo agoCompare

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

READMEChangelog (1)Dependencies (2)Versions (3)Used By (0)

Yii2 Redis Extension
====================

[](#yii2-redis-extension)

### Yii2官方的redis扩展功能太弱，不能主从不能集群，现在用第三方Predis类库来实现。

[](#yii2官方的redis扩展功能太弱不能主从不能集群现在用第三方predis类库来实现)

注意
--

[](#注意)

实现支持session

实现支持cache

未实现ActiveRecord

有些redis命令在集群等模式不可用

安装
--

[](#安装)

```
composer require  mojifan/yii2-predis

```

配置
--

[](#配置)

在配置文件添加如下配置：

单机：

```
'redis' => [
            'class' => 'mojifan\redis\Connection',
            'servers'=>[
                ['host' => '127.0.0.1','port'=> 6379],
            ],
        ],

```

redis集群：

```
'redis' => [
            'class' => 'mojifan\redis\Connection',
            'servers'=>[
                ['host' => '127.0.0.1','port'=> 6379],
                ['host' => '127.0.0.1','port'=> 6380],
                ['host' => '127.0.0.1','port'=> 6381],
            ],
            'options'=>['cluster' => 'redis'],
        ],

```

`servers`和`options`参数具体配置可以参考preids `Predis\Client($parameters, $options)`的`$parameters`和`$options`参数配置。

### session组件配置

[](#session组件配置)

```
        'session' => [
            'class' => 'mojifan\redis\Session',
        ],

```

### cache组件配置

[](#cache组件配置)

```
'cache' => [
            'class' => 'mojifan\redis\Cache',
        ],

```

###  Health Score

35

—

LowBetter than 79% of packages

Maintenance57

Moderate activity, may be stable

Popularity0

Limited adoption so far

Community8

Small or concentrated contributor base

Maturity64

Established project with proven stability

 Bus Factor1

Top contributor holds 80% 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 ~3008 days

Total

2

Last Release

283d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/37ed274034c97362d4dc74c872eaabb168d0daeec72727fd895830251de3eb00?d=identicon)[zkc](/maintainers/zkc)

---

Top Contributors

[![wensiti](https://avatars.githubusercontent.com/u/3906042?v=4)](https://github.com/wensiti "wensiti (4 commits)")[![zkc226](https://avatars.githubusercontent.com/u/14890199?v=4)](https://github.com/zkc226 "zkc226 (1 commits)")

### Embed Badge

![Health badge](/badges/zkc-yii2-predis/health.svg)

```
[![Health](https://phpackages.com/badges/zkc-yii2-predis/health.svg)](https://phpackages.com/packages/zkc-yii2-predis)
```

###  Alternatives

[pdffiller/qless-php

PHP Bindings for qless

29113.2k1](/packages/pdffiller-qless-php)[mojifan/yii2-predis

Redis Cache, Session for the Yii2

2257.2k](/packages/mojifan-yii2-predis)

PHPackages © 2026

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