public function load($oCategory, $id, $attributes = array())
{
if (null !== $attributes || !Mage::app()->useCache('catalog_models')) {
return parent::load($oCategory, $id, $attributes);
}
// Caching product data
Varien_Profiler::start(__METHOD__);
$storeId = (int) $oCategory->getStoreId();
$cacheId = "category-{$id}-{$storeId}";
if ($cacheContent = Mage::app()->loadCache($cacheId)) {
$data = unserialize($cacheContent);
if (!empty($data)) {
$oCategory->setData($data);
}
} else {
parent::load($oCategory, $id, $attributes);
// You can call some heavy methods here
try {
$cacheContent = serialize($oCategory->getData());
$tags = array(Mage_Catalog_Model_Category::CACHE_TAG, Mage_Catalog_Model_Category::CACHE_TAG . '_' . $id);
$lifetime = Mage::getStoreConfig('core/cache/lifetime');
Mage::app()->saveCache($cacheContent, $cacheId, $tags, $lifetime);
} catch (Exception $e) {
// Exception = no caching
Mage::logException($e);
}
}
Varien_Profiler::stop(__METHOD__);
return $this;
}