Created
August 24, 2014 18:41
-
-
Save ivanweiler/6098439a5c45e3e09b7b to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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