Skip to content

heartshare/yii2-predis

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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

About

Yii2 Redis Extension

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages