public function filters()
{
return array(
array(
'COutputCache',
'duration'=>3600,
'varyByParam'=>array('languages', 'value'),
),
);
}
The site loads the content with the parameter language and value.
The Cache is working well, but I need the Id from the cached side. The site is static and can stay a long time in cached version until i make an update of the content.
Then I need the id from the site to delete the old site from the cache! But from where I get the id??
My Workflow is as follow:
Write a new dynamic site and save the data in the database
When the user calls the content, the site is cached in APC
When I update the content, I need the id from the old cached site to delete it.
Then I need a method to call the cache and get an cached site.
CacheKey is used to save and get data from cache. But I was not right in previous answer, the better way is using cache dependency. You may add field to your database table where you will store the time of last update and create dependency which uses this field. In this case the cache will be refreshed when the value of this field changes.
COutputCache store in cache whole page’s content and that’s why it can not be bound to the id of database table, because controller’s action is not bound to any model directly. You may store in cache not whole page but only the data you get from database.
May be you must learn more. For example, CGlobalStateCacheDependency works fine for me. Thanks to this page cache scheme, my slow pages got x200 faster.
When you create/update/delete the new record, you should alter the global state using afterSave() or afterDelete() in your model.