标签:
在使用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;
}
标签:
原文地址:http://www.cnblogs.com/yuqianwen/p/5010348.html