« Return to Thread: Zend_Cache, storing objects

Zend_Cache, storing objects

by Johannes Schill :: Rate this Message:

Reply to Author | View in Thread

Hello,

I have some trouble with Zend_Cache.

Im trying to store objects in my cache, but it seems like if everything isnt stored. Is there anything wrong with the automatic serialization or am i just missing something (probably doing something wrong as usual:) )

Code:

In my bootstrap:

Zend_Loader::loadClass('Zend_Cache');
$cacheFrontendOptions = array(
    'lifetime' => $config->cache->lifetime, // cache lifetime, set to 10 (seconds)
    'automatic_serialization' => $config->cache->serialization, // true
);

$cacheBackendOptions = array(
    'cache_dir' => $config->cache->directory // Directory where to put the cache files
);

$cache = Zend_Cache::factory('Core', 'File', $cacheFrontendOptions, $cacheBackendOptions);
Zend_Registry::set('cache', $cache);


Then in my controller:

$this->_cache = Zend_Registry::get('cache');

if (!$artistRowset = $this->_cache->load('test')) {
    $artistRowset = $ma->findByName($artist); // $ma is a model
    $this->_cache->save($artistRowset, 'test');
} else {
    echo "This one is from cache!\n\n";
}

print_r($artistRowset);
die;


OK. The first error i got was:
"__PHP_Incomplete_Class Object ( [__PHP_Incomplete_Class_Name] => Zend_Db_Table_Rowset....."

So i added this to my bootstrap:
Zend_Loader::loadClass('Zend_Db_Table_Rowset');

..which made the incomplete-class-object-error disappear, but the object is still incomplete (when i print_r() the object it looks different when it comes from the cache).

Anyone who can point me in the right direction? Thanks in advance!

Cheers,
Johannes











 « Return to Thread: Zend_Cache, storing objects