您好我想将我的对象存储在缓存中。怎么做呢
请查看以下示例。
public function getMyCollection () {
$cacheKey = 'DIRECTORY_FEATURES_PRODUCT_STORE_' . Mage::app()->getStore()->getCode();
if (Mage::app()->useCache('config') && $cache = Mage::app()->loadCache($cacheKey))
{
$options = unserialize($cache);
} else
{
$options = Mage::getResourceModel('catalog/product_collection')
->addAttributeToSelect(array('name', 'price', 'small_image', 'short_description'), 'inner')
->addAttributeToSelect('news_from_date')
->addAttributeToSelect('news_to_date')
->addAttributeToSelect('special_price')
->setPageSize(8)
->addAttributeToSelect('status')
->addAttributeToFilter('visibility', array(2, 3, 4))
->addAttributeToSelect('*')
->addCategoryFilter(Mage::getModel('catalog/category')->load($this->catId()));
if (Mage::app()->useCache('config')) {
Mage::app()->saveCache(serialize($test), $cacheKey, array('config'));
}
}
return $options;
//return $this->products;
}
但它没有工作。我想加快我的主页和功能产品需要4秒才能加载,但如果我禁用功能滑块,则需要0.7秒来加载主页。
你能指导我做我必须做的事吗。