Browsing articles tagged with " Zend_Feed"
Apr
22
22
Zend Cache and Zend Feed Problem
Today I ran into a problem while caching feeds using Zend_Cache. I decided that I wanted to cache the returned object by the Zend_Feed. I had something like this:
$rssFeedLink = 'http://www.smooka.com/blog/';
$cacheId = 'rss_feed';
$frontendOptions = array(
'lifetime' => 1800, // cache lifetime of 30 mins
'automatic_serialization' => true);
$backendOptions = array(
// Directory where to put the cache files
'cache_dir' => '/cache/'
);
// getting a Zend_Cache_Core object
$cache = Zend_Cache::factory('Core','File', $frontendOptions, $backendOptions);
if (!$rss = $cache->load($cacheId)) {
try {
$rss = Zend_Feed::import($rssFeedLink);
} catch (Exception $e) {
$feedError = true;
}
//check to see if it did not fail
if (!$feedError && is_object($rss))
{
$cache->save($rss, $cacheId);
}
}
//assuming that everything went right while fetching the feed
foreach ($rss as $item) {
$channel['items'][] = array(
'title' => $item->title(),
'link' => $item->link(),
'description' => $item->description()
);
}
Recent Posts
Tags
add-on
Ajax
alerts
api
application
Apps
border-radius
charts
CMS
CSS
CSS3
CURL
debug
dojo
Facebook
firebug
firefox
getsimple
google
iPhone
jAlert
JavaScript
jQuery
Linux
log
messages
optimization
PHP
plug-in
programming
prototype
Resources
session
squareit
tips
tweetmeme
Ubuntu
wildfire
XML
yahoo
Zend
Zend Framework
Zend Studio
Zend_Cache
Zend_Feed



