Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/275.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/hadoop/6.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php Yii使用beginCache/endCache缓存主布局文件_Php_Caching_Yii - Fatal编程技术网

Php Yii使用beginCache/endCache缓存主布局文件

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

在Yii中,我的主布局和$content已经更改,因此我不需要缓存它。 我的想法是缓存
主布局
文件(包含$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'),
        ),
     );
  }