Hi all, I'm relatively new with ZF and completely new to the lists - so I
apologies if this is the wrong list.

I'm trying to cache the Twitter public timeline for 60 seconds, using the
code below:

$frontendOptions = array(
    'lifetime' => 60,
    'automatic_serialization' => true
);

$backendOptions = array('cache_dir' => APPLICATION_PATH . '/../tmp/');

$cache = Zend_Cache::factory(
    'Core',
    'File',
    $frontendOptions,
    $backendOptions);

if (!($timeline = $cache->load('publicTimeline'))) {
    $timeline = $this->_twitter->status->publicTimeline();
    $cache->save($timeline);
}

print_r($timeline);

This works fine on the first run, but the second and later runs (up till the
cache expires) I get this error:

*Warning*: unserialize()
[function.unserialize<http://localhost/home/timeline/function.unserialize>]:
Node no longer exists in *D:\twitter\library\Zend\Cache\Core.php* on line *278
        (x91)*
Zend_Rest_Client_Result Object ( [_sxml:protected] => SimpleXMLElement
Object
*Warning*: print_r()
[function.print-r<http://localhost/home/timeline/function.print-r>]:
Node no longer exists in *
D:\twitter\application\modules\home\controllers\TimelineController.php* on
line *58*
( ) )

I've tried storing a simple array and a small stdClass Object and they work
fine. I had an idea it could be to do with references but when I store an
instance of Zend_Registry in the object that works fine too.

I'm completely at a loss here - I'm practically following the reference
guide examples. If anyone can help I'd be grateful.

Regards,
Ross

(Extra)
If I store $timeline->status rather than the whole $timeline object the
array is stored but I still get 4 unserialize errors and this error:
*Warning*: Home_TimelineController::publicAction() [
home-timelinecontroller.publicaction<http://localhost/home/timeline/home-timelinecontroller.publicaction>]:
Node no longer exists in *
D:\development\twitter\application\modules\home\controllers\TimelineController.php
* on line *53   *( Line 53: if (!($timeline =
$cache->load('publicTimeline'))) { )*
*
-- 
Ross Masters [EN, GMT+0]
   Twitter: @rossmasters

Reply via email to