mojifan/yii2-predis

Redis Cache, Session for the Yii2

This package's canonical repository appears to be gone and the package has been frozen as a result.

Installs: 57 190

Dependents: 0

Suggesters: 0

Security: 0

Stars: 22

Watchers: 3

Forks: 9

Open Issues: 1

Type:yii2-extension

1.0.0 2017-05-07 15:50 UTC

This package is not auto-updated.

Last update: 2024-07-01 15:29:08 UTC


README

Yii2 Redis Extension

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'],
        ],

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

session组件配置

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

cache组件配置

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