8

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?

Community
  • 1
  • 1
Markie
  • 760
  • 17
  • 32

2 Answers2

11

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.

Axel
  • 10,732
  • 2
  • 30
  • 43
3

here you can find good explanation regarding difference between "Flush Cache Storage" and "Flush Magento Cache".

I agree that you should create CRON TASK (if clean cache is really necessary) (how to) with method:

public function flushAllAction()
{
    // Additional code if necessary
    Mage::app()->getCacheInstance()->flush();
    // Additional code if necessary
}

If you need further help don't hesitate to ask.

xyz
  • 2,277
  • 2
  • 25
  • 41