tinymeng/yii2-redis

Redis Cache, Session for the Yii2

Installs: 2

Dependents: 0

Suggesters: 0

Security: 0

Stars: 1

Watchers: 0

Forks: 0

Open Issues: 0

Type:yii2-extension

dev-master 2018-12-27 04:08 UTC

This package is auto-updated.

Last update: 2020-03-27 07:46:06 UTC


README

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

注意

实现支持session

实现支持cache

未实现ActiveRecord

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

安装

composer require  tinymeng/yii2-redis dev-master

配置

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

单机:

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