newbie
newbie

Reputation: 24645

How can I use Magento cache in widget?

I'm developing RSS feed widget for Magento. Now I need to use Magento cache to store feeds, so that feeds are not loaded on every request. How can I store my own items to Magento cache or is that possible at all?

What I need is :

// My item
$myItem = "My feed";

// Put stuff to cache
$cache->put("MyCacheId", $myItem);

// Get stuff from cache
$cache->get("MyCacheId");

Upvotes: 0

Views: 423

Answers (2)

davidselo
davidselo

Reputation: 1325

You can put the widget into a block and cached this block

Upvotes: 0

ngocanhdoan
ngocanhdoan

Reputation: 54

Mage_Core_Model_App::saveCache($data, $id, $tags=array(), $lifeTime=false)

is your desired method here.

In core you'll often find method access like follow:

Mage::app()->saveCache(serialize($myData), $myCacheKey, ...)

Good luck.

Upvotes: 1

Related Questions