编辑composer.json文件
vim composer.json
加入"yiisoft/yii2-redis": "~2.0.0"
执行更新
composer update
配置Yii的component
'redis' => [
'class' => 'yii
edisConnection',
'hostname' => 'localhost',
'port' => 6379,
'database' => 0,
],
验证
public function actionTest()
{
Yii::$app->redis->set('test','hello yii2-reids'); //设置redis缓存
echo Yii::$app->redis->get('test'); //读取redis缓存
exit;
return $this->render('test');
}
页面输出