1

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.

asked Apr 8, 2019 at 11:57

1 Answer 1

0
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
answered Jan 22, 2020 at 13:30

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.