|
View:
New views
3 Messages
—
Rating Filter:
Alert me
|
|
|
Zend_Cache, storing objectsHello,
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 |
|
|
Re: Zend_Cache, storing objects2007/6/6, Johannes Schill <johannes80@...>:
> 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:) ) > [...] I think this piece of PHP manual could help you : --------------------------------------------------------------------------------------------------- In order to be able to unserialize() an object, the class of that object needs to be defined. That is, if you have an object $a of class A on page1.php and serialize this, you'll get a string that refers to class A and contains all values of variabled contained in $a. If you want to be able to unserialize this on page2.php, recreating $a of class A, the definition of class A must be present in page2.php. This can be done for example by storing the class definition of class A in an include file and including this file in both page1.php and page2.php. --------------------------------------------------------------------------------------------------- Regards, -- Fabien MARTY fabien.marty@... |
|
|
Re: Zend_Cache, storing objectsThank you!
On 6/6/07, Fabien MARTY <fabien.marty@...> wrote: 2007/6/6, Johannes Schill <johannes80@...>: |
| Free embeddable forum powered by Nabble | Forum Help |