To create new cache type in magento, only add this code to config.xml of your extensions
when you want use your cache type. we can use this code below.Description of cache type. YOUR_CACHE_TAG
so, now, we have 1 problem , that is : how to refresh all cache associate with that cache type. this is 1 solution to do it: the first , i create a observer for event : adminhtml_cache_refresh_type. Can you add this code in global tag in config.xml
$cacheGroup = 'your_cache_type';
$useCache = Mage::app()->useCache($cacheGroup);
if (true === $useCache) {
// Cache is active
} else {
// Cache is not active
}
now, we can create file name as: Observer.php follow this path: YourNameSpace/YourExtenstion/Model/Observer.php and add this code in to Observer.phpsingleton YourNameSpace_YourExtenstion_Model_Observer adminhtml_cache_refresh_type
class YourNameSpace_YourExtenstion_Model_Observer
{
public function adminhtml_cache_refresh_type($observer)
{
$request = Mage::app()->getRequest()->getPost('types');
if(in_array('ee_content', $request))
{
$cache = Mage::app()->getCache();
$tags = $cache->getTags();
$ee_content = '';
foreach($tags as $tag)
{
if(strpos($tag, 'ee_content'))
{
$ee_content = $tag;
}
}
if($ee_content !='')
{
$ids = $cache->getIdsMatchingAnyTags(array($ee_content));
foreach($ids as $id)
{
$cache->remove($id);
}
}
}
}
}