Zend_Cache - "Data must be string or set automatically_serialization = true"

I am trying to cache an array with Zend_Cache as follows:

$cache = Zend_Registry::get('cache');
// $data is an array
$cache->save($data, 'externalData');

And I get this error:

Message: Datas must be string or set automatic_serialization = true

Although initializing Zend_Cache in the bootstrap file, the auto_serialization parameter is set to tu true:

protected function _initCache()
{
    $frontend= array('lifetime' => 7200,
                     'automatic_seralization' => true);
    $backend= array('cache_dir' => 'cache');
    $this->cache = Zend_Cache::factory('core',
                                       'File',
                                       $frontend,
                                       $backend);
}

What can cause this error message?

+3
source share
1 answer

Perhaps you just made a copy or impression mistake, but in the code you posted you have:

$frontend= array('lifetime' => 7200,
                 'automatic_seralization' => true);

i.e. you set automatic_seralizationto true, not automatic_serialization: pay attention to i in ser i -alization.

+5
source

Source: https://habr.com/ru/post/1732070/


All Articles