Coutputcache Clear

I want to ask, how can I clear cache for some pages. For example I have page which can user change sometimes and after change I want to clear COutputCache but only for changed page.

Can you help me, please.

Thanks a lot.

AFAIK Yii doesn’t support flushing the cache partial.

Only an idea, not tested:

You should call the Yii::app()->cache->delete() indirect with the generated cachekey from the COutputCache.

COutputCache::getIsContentCached() should do the job, if the duration property is 0.

Add a method like this to your controller.





public function flushPageCache($id,$properties=array()) {


   $properties['id']=$id;

   $properties['duration']=0;

   $outputCache = $this->createWidget('COutputCache',$properties);

   

   //this line should delete the value from the app-cache generated by the COutputCache

   //calls Yii::app()->cache->delete($outputCache->getCacheKey()); ?? see: COutputCache::getIsContentCached()

   

   $outputCache->getIsContentCached();

}


Call the flushPageCache with the same id/properties you have called $this->beginCache('pageId');






But problem is, that I use COutputCache in filter function:




public function filters() {

        return array(

            'accessControl',

			array(

				'COutputCache + view',

				'duration' => 1800,

				'varyByParam' => array('id'),

				'varyByLanguage' => TRUE

			),

        );

    }



My idea is to create class extends COutputCache and store in cache pair: unique ID ‘view_XY’ and COutputCache unique id. Then I can clean cache by Yii::app()->cache->delete($id), but I have problem to get some XY data.

Sorry for my english.