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(11mo ago)00MITPHP

Since May 7Pushed 11mo 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 today

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

33

—

LowBetter than 72% of packages

Maintenance52

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

337d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/5368526?v=4)[zkc](/maintainers/zkc)[@zkc](https://github.com/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

[craftcms/cms

Craft CMS

3.6k3.6M3.1k](/packages/craftcms-cms)[unopim/unopim

UnoPim Laravel PIM

10.5k2.4k](/packages/unopim-unopim)[symfony-bundles/redis-bundle

Symfony Redis Bundle

291.2M7](/packages/symfony-bundles-redis-bundle)[millipress/millicache

WordPress Full-Page Cache based on Rules &amp; Flags. Delivers flexible, scalable caching workflows backed by Redis and ValKey in-memory stores.

722.9k2](/packages/millipress-millicache)[mojifan/yii2-predis

Redis Cache, Session for the Yii2

2257.2k](/packages/mojifan-yii2-predis)[lion/bundle

Lion-framework configuration and initialization package

122.4k4](/packages/lion-bundle)

PHPackages © 2026

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