Welcome, Guest. Register Now!
   
Mark Forums Read Mark Forums Read Mark Forums Read


Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 07-05-2007, 06:58 AM
Junior Member
 
Join Date: Jun 2007
Location: perth, australia
Posts: 11
Default Zend Cache + Zend Feed Rss, not happy together

I sent this to the mailing list but no harm asking here as well

I'm basically caching a feed so its not requested on every page hit. Here's my
code
PHP Code:
//load the cache
Zend_Loader::loadClass('Zend_Cache');
//load up Zend_Feed
Zend_Loader::loadClass('Zend_Feed_Rss');
    
$cache_f = array(
'lifetime' => 60*5,
'automatic_serialization' => true
);
 
$cache_b = array(
'cache_dir' => '../cache/'
);
 
$cache Zend_Cache::factory('Core''File'$cache_f$cache_b);
 
if (!
$lastFM $cache->load('lastfm')) {
    
$lastFM = new 
Zend_Feed_Rss('http://ws.audioscrobbler.com/1.0/user/santouras/recenttracks.rss');
    
    
$cache->save($lastFM'lastfm');

On first load I get this error when I save the cache

Code:
Warning: Invalid argument supplied for foreach() 
in /opt/lampp/htdocs/santouras/library/Zend/Feed/Element.php on line 322
On subsequent loads the object looks like it has all its data in there
correctly, just that this warning is being thrown. Any ideas?
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #2 (permalink)  
Old 07-05-2007, 07:53 AM
Maugrim The Reaper's Avatar
Junior Member
 
Join Date: Jun 2007
Location: Ireland
Posts: 20
Default

Can you check if the warning occurs when Zend_Cache is removed from the equation?

It might, possibly, just be an invalid RSS document. Happens sometimes. But certaintly let the mailing list know (don't see your post there yet?) so someone working on Zend_Feed can take a better look.
__________________
Pádraic Brady

http://blog.astrumfutura.com
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #3 (permalink)  
Old 07-05-2007, 07:56 AM
Junior Member
 
Join Date: Jun 2007
Location: perth, australia
Posts: 11
Default

Script works beautifully without the cache in there. I haven't actually tried it with another feed which I'll do later on today
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #4 (permalink)  
Old 02-05-2008, 05:20 PM
Junior Member
 
Join Date: Feb 2008
Posts: 1
Default

Anyone know if this was ever resolved?

im trying to do pretty much the same thing, but with an object, not the rss feed. I thought i could just pass objects into the cache object...obviously not!
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #5 (permalink)  
Old 02-08-2008, 11:09 AM
Junior Member
 
Join Date: Feb 2008
Posts: 2
Default

I'm also interested in the resolution to this problem. I'm in the same situation of santouras.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #6 (permalink)  
Old 05-22-2008, 06:26 PM
Junior Member
 
Join Date: May 2008
Posts: 1
Default Found solution

The problem is that the Zend_Feed_Rss object is being put to sleep, but not woken after serializing by the Zend Cache.

Add this line after calling $cache->save(...):

$lastFM->__wakeup();

This is definitely a bug. Now, whether it's with the Zend_Feed_Rss, or with Zend_Cache, I don't know.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #7 (permalink)  
Old 05-28-2008, 10:30 AM
Junior Member
 
Join Date: Oct 2007
Posts: 27
Default

I had a similar problem with caching because the XML references in the Feed's objects were not valid. Wakeup probably would have fixed this but I couldn't figure it out at the time.

As I was loading content from several feeds, merging, and sorting by date my solution was to put data from the entries into a two dimensional array and cache that array. So the array just contained arrays of strings, rather than the elements themselves.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



All times are GMT. The time now is 03:34 AM.