Skip to content

Instantly share code, notes, and snippets.

@ivanweiler
Created August 24, 2014 18:41
Show Gist options
  • Save ivanweiler/6098439a5c45e3e09b7b to your computer and use it in GitHub Desktop.
Save ivanweiler/6098439a5c45e3e09b7b to your computer and use it in GitHub Desktop.
<?php
class Inchoo_Edu_Model_Example
{
/*
* Custom cache example
*
* @see: Directory, Adminhtml_Block, etc.
*
*/
public function getData()
{
$cacheKey = 'INCHOO_EDU_DATA';
if (Mage::app()->useCache('config') && $cache = Mage::app()->loadCache($cacheKey)) {
$result = unserialize($cache);
} else {
// REAL LOGIC GOES HERE
$result = $this->getRealData();
if (Mage::app()->useCache('config')) {
Mage::app()->saveCache(serialize($result), $cacheKey, array('config'), 24*60*60);
}
}
}
public function getRealData()
{
//hard core query, curl data, etc.
return array('I','am','Inchooer');
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment