在使用YII自身缓存时,在main.php文件配置中一定要配置keyPrefix,如下图:

'cache' => array(
  'class' => 'CFileCache',
  'keyPrefix' => 'ivyonline',
),

如果不配置,造成缓存删除不了的问题(另:自己生成的缓存,自己可以删除),上YII源码如下:

/**
* Initializes the application component.
* This method overrides the parent implementation by setting default cache key prefix.
*/
public function init()
{
      parent::init();
      if($this->keyPrefix===null)
           $this->keyPrefix = Yii::app()->getId();
      }

/**
* @param string $key a key identifying a value to be cached
* @return string a key generated from the provided key which ensures the uniqueness across applications
*/
protected function generateUniqueKey($key)
{
       return $this->hashKey ? md5($this->keyPrefix.$key) : $this->keyPrefix.$key;
}

使用YII缓存注意事项的更多相关文章

  1. YII缓存Cache

    缓存Cache 定义:将数据暂时存放在一个存储速度更快的介质上,下次读取数据时就可以从这个介质上来读取数据 介质:内存.文件.数据库(优化好的数据库) Yii缓存的分类:(framework/cach ...

  2. YII缓存依赖的应用

    YII缓存依赖的应用 缓存 缓存依赖 Yii 缓存是提升Web应用性能的简便有效的方式.当我们在加载网页需要过多的时间,比如说查询时间过久,抑或是调用接口占用过多I/O,建立缓存是一个行之有效的方法, ...

  3. yii 缓存的使用 以及使用需要开启php的apc扩展

    public function behaviors() { return [ [ 'class' => 'yii\filters\PageCache', 'only' => ['index ...

  4. yii缓存设置使用

    'filecache'=>array( 'class'=>'system.caching.CFileCache', 'directoryLevel'=>'3',), //在main. ...

  5. yii 缓存探究

    1.在配置文件中 //在权威指南上是'cache' 其实可以根据不同的缓存组件起不同的名称 //memcache缓存 'memcache' => array( 'class' => 'sy ...

  6. yii 缓存之apc

    首先yii CApcCache 实现了一个针对APC的缓存应用组件,常见的缓存操作方法get,set,add,delete,flush... 下面说说配置: 1. 在config/main.php c ...

  7. YII缓存整理

    缓存 缓存是用于提升网站性能的一种即简单又有效的途径.通过存储相对静态的数据至缓存以备所需,我们可以省去生成这些数据的时间.在 Yii 中使用缓存主要包括配置和访问缓存组件 . 如下的应用配置指定了一 ...

  8. YII缓存之数据缓存

    1.开启缓存组件 2. ================ 二 先在配置文件components数组中加上: 'cache'=>array( 'class'=>'CFileCache'), ...

  9. YII缓存操作

    //文件依赖 $dependency = new \yii\caching\FileDependency(['filename'=>'hw.txt'])}; $cache->add(&qu ...

随机推荐

  1. Refusing to install package with name "webpack" under a package

    最近学习webpack 知识时 下载依赖结果报了这个错 查阅资料后发现是 这个name 不能使用所需要安装包的名字! 换为其他之后 再次操作命令 就没问题了

  2. 查询 keystore文件的签名信息

    需要安装jdk 在安装 jdk的/bin文件夹下 keytool -v -list -keystore [keystore文件的路径]

  3. 项目出现红色感叹号, pom.xml并出错

    问题描述: eclipse出现红色感叹号,pom.xml 文件也报错  但没有提示具体是那里出错了. 打开 Java Build Path  找到 Librarices 你在看到 Maven  Dep ...

  4. 【音乐欣赏】《Wrong》 - Far Out / Emilia Ali

    曲名:Wrong 作者:Far Out / Emilia Ali [00:16.03]Ride body on mine [00:18.07]Griping your waist as I was o ...

  5. Python环境搭建后,多种方式的使用进行程序的执行。

    Python环境搭建后,可以使用多种方式进行程序的执行. 第一种: 进入CMD命令提示符 输入python 进入python环境(可以使用Ctrl+C退出) 输入print("hello&q ...

  6. Python 报错 AttributeError: module 'django.db.models' has no attribute 'SubfieldBase'

    AttributeError: module 'django.db.models' has no attribute 'SubfieldBase' http://www.guanggua.com/qu ...

  7. LoadRunner通过验证参数判断事物的成功与失败

    if(atoi(lr_eval_string("{Param_DiscountID}")) > 0){ //lr_message("多机多酒:%s",lr ...

  8. VS常用快捷键(2012)

    Ctrl+K,D ----格式化全部代码 Ctrl+K,F ----格式化选中的代码 Ctrl+K,C ----注释选定内容 Ctrl+K,U ----取消注释选定内容 Ctrl+J或者 Ctrl+S ...

  9. 1、json背景

    教程链接 链接:http://pan.baidu.com/s/1mil4M1M 密码:vwsn JSON (JavaScript对象表示法)是一种轻量级的基于文本的开放标准,被设计用于可读的数据交换, ...

  10. linux下安装mongo数据库存

    https://www.runoob.com/mongodb/mongodb-linux-install.html 安装完后,要重启一下,否则无法运行./mongod 下载完安装包,并解压 tgz(以 ...