Skip to content

Instantly share code, notes, and snippets.

@CajuCLC
Created June 24, 2018 07:32
Show Gist options
  • Select an option

  • Save CajuCLC/b4e3e3034bba23ad923cec13192df9f0 to your computer and use it in GitHub Desktop.

Select an option

Save CajuCLC/b4e3e3034bba23ad923cec13192df9f0 to your computer and use it in GitHub Desktop.
<?php
/**
* Clear cache via CLI
*
* @category MageBR
* @author Eric Cavalcanti <cajuclc@gmail.com>
* @license MageBR License
* @link https://www.magebr.com
*/
echo "Start Cleaning all caches at ... " . date("Y-m-d H:i:s") . "\n\n";
ini_set("display_errors", 1);
require 'app/Mage.php';
Mage::app('admin')->setUseSessionInUrl(false);
Mage::getConfig()->init();
$types = Mage::app()->getCacheInstance()->getTypes();
try {
echo "Cleaning data cache... \n";
flush();
foreach ($types as $type => $data) {
echo "Removing $type ... ";
echo Mage::app()->getCacheInstance()->clean($data["tags"]) ? "Cache was cleared!" : "Something bad happened!";
echo "\n";
}
} catch (exception $e) {
die("[ERROR:" . $e->getMessage() . "]");
}
echo "\n";
try {
echo "Cleaning stored cache... ";
flush();
echo Mage::app()->getCacheInstance()->clean() ? "Cache was cleared!" : "Something bad happened!";
echo "\n\n";
} catch (exception $e) {
die("[ERROR:" . $e->getMessage() . "]");
}
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment