标签:压缩 hub local style soft 配置 col color .com
1 首先获取到 yii2-redis-master.zip 压缩包
下载地址
https://github.com/yiisoft/yii2-redis/archive/master.zip
2 把下载的扩展文件放到vendor/yiisoft/下,命名为yii2-redis
3 修改vender/yiisoft/下的extensions.php,加入redis扩展
‘yiisoft/yii2-redis‘ => array ( ‘name‘ => ‘yiisoft/yii2-redis‘, ‘version‘ => ‘2.2.0.0‘, ‘alias‘ => array ( ‘@yii/redis‘ => $vendorDir . ‘/yiisoft/yii2-redis‘, ), ),
4 配置Yii的component也就是config下的web.php中的components
‘redis‘ => [ ‘class‘ => ‘yii\redis\Connection‘, ‘hostname‘ => ‘localhost‘, ‘port‘ => 6379, ‘database‘ => 0, //‘password‘=>‘asdf123‘, ],
这样我们的redis就配置完成了,接下来就是验证了
public function actionIndex() { Yii::$app->redis->set(‘test‘,‘111‘); //设置redis缓存 echo Yii::$app->redis->get(‘test‘); //读取redis缓存 exit; return $this->render(‘index‘); }
此时运行程序,页面输出了“111”,就说明redis配置成功了
标签:压缩 hub local style soft 配置 col color .com
原文地址:https://www.cnblogs.com/liangzia/p/10868979.html