我正在为Magento开发RSS提要小部件。现在我需要使用Magento缓存来存储提要,这样就不会在每次请求时都加载提要。我如何将自己的物品存储到Magento缓存中,或者这可能吗?
我需要的是:
// My item
$myItem = "My feed";
// Put stuff to cache
$cache->put("MyCacheId", $myItem);
// Get stuff from cache
$cache->get("MyCacheId");
Mage_Core_Model_App::saveCache($data, $id, $tags=array(), $lifeTime=false)
是你想要的方法。
在核心中,你经常会发现方法访问如下:
Mage::app()->saveCache(serialize($myData), $myCacheKey, ...)
祝你好运。
您可以将小部件放入一个块中并缓存此块