I have redis which is hosted separably. I need to clean specific type of cache (i.e. block_html) using a script. The problem is that whenever I update product it doesn't reflect on the front-end side until I clean the cache type block_html.
I need to use a script to clean the cache. The script is working fine in default cache, however It doesn't clean cache while redis the cache is active. However Whenever I clean cache from backend It works.
I have searched a lot but I just found commands like redis-cli -h redis flushall which flush the cache of entire Magento however, I just want to clean / flush the cache of a specific type.
Is there any command/script to achieve this?
Script:
<?php
require_once("app/Mage.php");
Mage::app('admin');
Mage::register('isSecureArea', 1);
Mage::app()->setCurrentStore(Mage_Core_Model_App::ADMIN_STORE_ID);
$type = 'block_html';
Enterprise_PageCache_Model_Cache::getCacheInstance()->cleanType($type);
Mage::getConfig()->loadEventObservers('adminhtml');
Mage::app()->addEventArea('adminhtml');
//Mage::dispatchEvent('adminhtml_cache_refresh_type', array('type' => $input->getArgument('type')));
Mage::dispatchEvent('adminhtml_cache_refresh_type', array('type' => $type));
//Mage::app()->getCacheInstance()->cleanType('block_html');
//$test->clean();
echo "success";
Used Source:
https://github.com/samm-git/cm_redis_tools
http://info2.magento.com/rs/magentosoftware/images/MagentoECG-UsingRedisasaCacheBackendinMagento.pdf
Please suggest.
1 Answer 1
require_once("app/Mage.php");
Mage::app('admin');
Mage::register('isSecureArea', 1);
Mage::app()->setCurrentStore(Mage_Core_Model_App::ADMIN_STORE_ID);
$type = 'block_html';
Enterprise_PageCache_Model_Cache::getCacheInstance()->cleanType($type);
?>
try to execute above script in browser
Explore related questions
See similar questions with these tags.