手动安装yii2.0-redis扩展
1.点击下载:yii2.0-redis扩展
2.把下载的扩展文件放到vendor/yiisoft/下,命名为yii2-redis
3.修改vender/yiisoft/下的extensions.php,加入redis扩展
|
1
2
3
4
5
6
7
8
9
10
11
12
13
14
|
'yiisoft/yii2-redis' => array ( 'name' => 'yiisoft/yii2-redis', 'version' => '2.2.0.0', 'alias' => array ( '@yii/redis' => $vendorDir . '/yiisoft/yii2-redis', ), ),<br>4.配置yii的component<br><br>'redis' => [ 'class' => 'yii
edisConnection', 'hostname' => 'localhost', 'port' => 6379, 'database' => 0,], |
5.这样我们的redis就配置完成了,接下来就是验证了
|
1
2
3
4
5
6
7
|
public function actionIndex(){ Yii::$app->redis->set('test','111'); //设置redis缓存 echo Yii::$app->redis->get('test'); //读取redis缓存 exit; return $this->render('index');} |
页面输出了“111”,就说明redis配置成功了