您的位置:首页 > 数据库 > Redis

在yii框架下使用redis数据库

2017-09-27 14:20 274 查看


1.安装Yii的Redis插件

目前主要有两种Yii插件:

Ø  Rediscache:基于predis(Redis的纯PHP实现客户端),无需安装Redis for PHP扩展。

Ø  YiiRedis:基于phpredis客户端,需要安装Redis for PHP扩展。

这里采用Rediscache插件,避免线上安装Redis for PHP扩展。


1.1下载安装

从以下地址下载Rediscache插件:

http://www.yiiframework.com/extension/rediscache/files/redis.zip

 

将插件解压到helloyii/app/protected/extensions中:

插件文件部署后的位置应为:helloyii/app/protected/extensions/redis/CredisCache.php


1.2配置Rediscache

1.helloyii/app/protected/config/main.php

=============================================================================

 return array(

 'components' => array(

   …

   'cache'=>array(

    'class'=>'ext.redis.CRedisCache',     //对应protected/extensions/redis/CredisCache.php

    'servers'=>array(

     array(

      'host'=>'127.0.0.1',

      'port'=>6379,

     ),

    ),

   ),

  ),

  …

 );
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  php redis 数据库 yii