1、到composer.json下的repositories数组弄成空,这是个前台的包管理,加载慢费时
“repositories”: [
],
2、执行下句,使用中国镜像,加快速度
composer config -g repo.packagist composer https://packagist.phpcomposer.com
3、 common/config/common.php 文件,修改如下。
‘cache’ => [
// ‘class’ => ‘yii\caching\FileCache’,
‘class’ => ‘yii\redis\Cache’,
],
‘redis’ => [
‘class’ => ‘yii\redis\Connection’,
‘hostname’ => ‘localhost’,
‘port’ => 6379,
‘database’ => 0,
],
4、测试
Yii::
app−>cache−>set(‘test′,‘hehe..′);echoYii::
a
p
p
−
>
c
a
c
h
e
−
>
s
e
t
(
‘
t
e
s
t
′
,
‘
h
e
h
e
.
.
′
)
;
e
c
h
o
Y
i
i
::
app->cache->get(‘test’), “\n”;
Yii::
app−>cache−>set(‘test1′,‘haha..′,5);echo‘1‘,Yii::
a
p
p
−
>
c
a
c
h
e
−
>
s
e
t
(
‘
t
e
s
t
1
′
,
‘
h
a
h
a
.
.
′
,
5
)
;
e
c
h
o
‘
1
‘
,
Y
i
i
::
app->cache->get(‘test1’), “\n”;
sleep(6);
echo ‘2 ‘, Yii::$app->cache->get(‘test1’), “\n”;
5、http://www.cnblogs.com/52cik/p/yii2-redis-cache.html修改小坑
6、更多redis数据结构的使用
http://www.yiichina.com/tutorial/904?sort=desc
https://segmentfault.com/a/1190000009168489