redis配置不能生效 [ 2.0 版本 ]
config里面的redis设置在yii\redis\Connection类的init里面还是有的,到了open方法里面就变缺省的了.
打印出的东西是:
代码如下
'redis' => [
'class' => 'yii\redis\Connection',
'password'=>'111111',
'hostname' => '10.8.17.211',
'port' => 6379,
'database' => 0,
],
public function init()
{
parent::init();
echo $this->hostname.' '.$this->port.' '.$this->password.'<br>';
}
public function open()
{
echo $this->hostname.' '.$this->port.' '.$this->password.'<br>';
exit;
//........................
}
最佳答案
-
骚年你配置好后输出下
Yii::$app->redis
看看有没得东西,我这边使用redis是OK的,Yii2.共 2 条回复oniceriver 回复于 2015-06-30 13:11 回复找到原因了,习惯性的new了一下
$redis=new Yii::$app->redis;
直接$redis=Yii::$app->redis;
就好了jhomephper 回复于 2015-11-10 12:20 回复@oniceriver 有高级模板的redis扩展吗?我在高级版下安装这个没法用啊
strive 觉得很赞
oniceriver
注册时间:2015-06-30
最后登录:2015-08-14
在线时长:1小时25分
最后登录:2015-08-14
在线时长:1小时25分
- 粉丝0
- 金钱100
- 威望0
- 积分110