Tuesday, April 28, 2015

clear cache programatically on Magento

Method 1:

$typeArr = Mage::app()->useCache();

foreach ($typeArr as $k => $v) {
  Mage::app()->getCacheInstance()->cleanType($k);
}

Method 2:

$typeArr = Mage::app()->getCacheInstance()->getTypes();

foreach ($typeArr as $k => $v) {
  Mage::app()->getCacheInstance()->cleanType($k);
}

Method 3:

Mage::app()->getCacheInstance()->flush();

Method 4:

Mage::app()->getCache()->clean();

No comments: