yii2.0 手动配置redis

手动安装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\redis\Connection',
        '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配置成功了

上一篇:解决At least one JAR was scanned for TLDs yet contained no TLDs. Enable debug logging for this log


下一篇:Android Fragment应用实战