Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Magento "Flush Cache Storage"

I understand the difference between "Flush Magento Cache" and "Flush Cache Storage" in Magento (example). I'm trying to work on a cron job that will flush the cache storage from time to time.

I'm assuming that this button doesn't just remove the contents of var/cache/, but I can't find a solid resource that says what it does. I am using APC as well as all the inbuilt Magento cache features.

Is it possible to run the equivalent of the "Fluch Cache Storage" button from a script?

like image 217
Markie Avatar asked Feb 22 '13 15:02

Markie


1 Answers

In the app/code/core/Mage/Adminhtml/controllers/CacheController.php, you can see that flushAllAction() (the action that is called when you click Flush Cache Storage) is called.

This function contains the following:

/**
 * Flush cache storage
 */
public function flushAllAction()
{
    Mage::dispatchEvent('adminhtml_cache_flush_all');
    Mage::app()->getCacheInstance()->flush();
    $this->_getSession()->addSuccess(Mage::helper('adminhtml')->__("The cache storage has been flushed."));
    $this->_redirect('*/*');
}

To call this in your own file, you can do the following.

require_once('app/Mage.php');
Mage::app()->getCacheInstance()->flush();

Now, you can run your php file using a cronjob.

like image 158
Axel Avatar answered Sep 30 '22 03:09

Axel