实现支持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' => [
'class' => 'mojifan\redis\Session',
],
'cache' => [
'class' => 'mojifan\redis\Cache',
],