iFuel is Now Part of the Amsive Family! Read More

Magento Caching

Magento uses caching extensively. If you also want to be able to save something to cache rather than reading from the database or some more expense resource like that, it’s simple:

$value = Mage::app()->loadCache(‘my_cache_key’);

If the key isn’t found, $value will be null.

To store a value in the cache is almost as easy:

Mage::app()->saveCache($data_to_store, ‘my_cache_key’, array(), $duration_in_seconds);

(The empty array in the call above is standing in for a parameter called “tags” which, to my knowledge, is not used. Someone please correct me on that if I’ve got it wrong.)

TAGS: CachingMagento

Leave a Reply

XHTML: You can use these tags: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>