Using Magento cache to save custom key value data
Posted on June 5, 2014
Using Magento cache to save custom key value data
- You can connect your cache items to the default cache tags of magento for example BLOCK_HTML. This will ensure that your items will be removed, when magento removes block_html cache.
//Initiate Cache class
$cache = Mage::app()->getCache();
//Get Item
$cachedItem = $cache->load($key);
//Save Item
$cache->save($value, $key, $tags = array(), $lifeTime=null);
//Remove Item
$cache->remove($key);
//Remove all items with the given tags
$cache->clean($tags = array();