Php Yii使用beginCache/endCache缓存主布局文件
在Yii中,我的主布局和$content已经更改,因此我不需要缓存它。 我的想法是缓存Php Yii使用beginCache/endCache缓存主布局文件,php,caching,yii,Php,Caching,Yii,在Yii中,我的主布局和$content已经更改,因此我不需要缓存它。 我的想法是缓存主布局文件(包含$content的部分,来自视图文件): 我已将cache filters()放入主控制器: 组件/Controller.php 'cache'=>array( 'class'=>'system.caching.CFileCache', // 'connectionID'=>'db', // 'autoCrea
主布局
文件(包含$content的部分,来自视图
文件):
我已将cache filters()放入主控制器:
组件/Controller.php
'cache'=>array(
'class'=>'system.caching.CFileCache',
// 'connectionID'=>'db',
// 'autoCreateCacheTable'=>false,
// 'cacheTableName'=>'cache',
),
'memcache'=>array(
'class'=>'system.caching.CMemCache',
),
class Controller extends CController
{
public function filters()
{
return array(
'accessControl', // perform access control for CRUD operations
'postOnly + delete', // we only allow deletion via POST request
array(
'COutputCache',
'duration'=>1000,
'varyByParam'=>array('id'),
),
);
}
我不确定我的方法是否正确。我还关心$id
-应该是什么类型的?
经过一些测试,我发现性能没有大的提高。。。
您能评论/纠正我吗?您的配置文件似乎有误。你已经启用了2个大笑?CFileCache和CMemCache 请看参考资料: 正确的配置应为:
“缓存”=>阵列(
'class'=>'system.caching.CFileCache',
),
在您的配置中完全允许有两个缓存组件。大多数内置功能只使用名为“缓存”的功能。如果你需要第二个,这不一定会阻止你。
class Controller extends CController
{
public function filters()
{
return array(
'accessControl', // perform access control for CRUD operations
'postOnly + delete', // we only allow deletion via POST request
array(
'COutputCache',
'duration'=>1000,
'varyByParam'=>array('id'),
),
);
}