我试图用Zend_Cache缓存一个数组,如下所示:
$cache = Zend_Registry::get('cache'); // $data is an array $cache->save($data, 'externalData');
我收到这个错误:
Message: Datas must be string or set automatic_serialization = true
即使在bootstrap文件中初始化Zend_Cache时设置了true_serialization:
protected function _initCache() { $frontend= array('lifetime' => 7200, 'automatic_seralization' => true); $backend= array('cache_dir' => 'cache'); $this->cache = Zend_Cache::factory('core', 'File', $frontend, $backend); }
什么可能导致此错误消息?
也许您只是制作了复制粘贴错误或拼写错误,但是,在您发布的代码中,您有:
$frontend= array('lifetime' => 7200, 'automatic_seralization' => true);
即要设置automatic_seralization
为true,而不是automatic_serialization
:注意我在丝氨酸我 -alization.