Increase server performance with Magento Caching

Magento Uses multi level of caching based on Zend framework. Most of which are transparent to developers.
From very top  Magento stores cache data in two different types of back end.
i) Very fast cache like APC, Memcached, Solr, Redis..etc.
ii) A slow like file system.

Each cache medium  like APC, Memcached, Redis uses their own strategy to store data uses key value as backend. The data are stored in cache with meta data. These meta data are used for mass deletion of cache values. These cachings are controlled in magento through Cache API only.

The Cache API
The caching system in mangento is controlled by  Mage_Core_Model_Cache. Which is typically access the cache through an already instantiated object accessible at Mage::app()->getCache().
The implementation of these cache are hidden from us, but their actual implementation are done through below methods only.
save($value, $key, $tags = array(), $lifeTime=null)
clean($tags = array()
See Magento Caching Example in action

If you want to see how magnto caching works simply use

$cache = Mage::app()->getCache();

here $cache instantiate the object of magento cache and with this object you can store your value into cache itself

$cache->save(date("y-m-d"), "nice_date", array("nice_cache"), 10);
$cache->save("hello cache world - " . time(), "nice_hellocacheworld", array("nice_cache"), 60*60);

With the above example I have instructed the cache to store the value of the current date with the $key nice_date.  I’ve also stored the phrase hello cache  world – 601992000 (any timestamp) with the $key nice_hellocacheworld .
To fetch the value of a key from cache, we simply use:
To remove individual values from the cache, we use:
To clean

The following two tabs change content below.

Chandra Shekhar

GCP Architect
Chandra Shekhar Pandey is Google certified Cloud engineer, I am Magento2 Trained developer. Having huge experience in designing cloud solution. I have around 12 years of experience with world enterprise IT companies and fortune 500 clients. During my architecture design I am always caring about high availability, fast performance and resilient system. From the programmer background I have huge experience in LAMP stack as well. Throughout my carrier I have worked on Retail, E-Learning, Video Conferencing and social media domain. The motive of creating cutehits was just to share the knowledge/solutions I get to know during my day to day life so that if possible I can help someone for same problems/solutions. is a really a very effort for sharing knowledge to rest of the world. For any query/suggestion about same you can contact me on below details:- Email: shekharmca2005 at Phone: +91-9560201363

Latest posts by Chandra Shekhar (see all)

You may also like...