Php 如何在Zend Framwork2的memcahe中保存XMLobject
下面是我的代码部分(在Php 如何在Zend Framwork2的memcahe中保存XMLobject,php,zend-framework,xml-parsing,zend-framework2,memcached,Php,Zend Framework,Xml Parsing,Zend Framework2,Memcached,下面是我的代码部分(在ZF2中),我试图将一个XML对象保存到Memcache中,但我不明白为什么不将复杂的obejct设置到Memcache,有什么线索吗 $serviceManager = $event->getApplication()->getServiceManager(); $xmlAclConfigCache = $serviceManager->get('memcache')->getItem('xmlConfig');
ZF2
中),我试图将一个XML对象保存到Memcache
中,但我不明白为什么不将复杂的obejct设置到Memcache
,有什么线索吗
$serviceManager = $event->getApplication()->getServiceManager();
$xmlAclConfigCache = $serviceManager->get('memcache')->getItem('xmlConfig');
if (empty($xmlAclConfigCache)) {
echo 'fresh ACL XML';
$xmlAclConfigCache = simplexml_load_file(__DIR__.'/config/acl.xml');
$serviceManager->get('memcache')->setItem('xmlConfig', $xmlAclConfigCache);
var_dump($xmlAclConfigCache);
} else {
echo 'OLD ACL XML';
}
Memcache
config incache.local.php
<?php
return array(
'caches' => array(
'memcache' => array( //can be called directly via SM in the name of 'memcached'
'adapter' => array(
'name' =>'memcache',
'ttl' => 7200,
'options' => array(
'servers' => array(
array(
'127.0.0.1',11211
)
),
'namespace' => 'MYMEMCACHEDNAMESPACE',
)
),
'plugins' => array(
'exception_handler' => array(
'throw_exceptions' => false
),
),
),
),
);
memcache服务的配置是什么?@akond配置为服务管理器我的意思是显示配置。@akond添加了请查看编辑我猜配置缺少插件“序列化器”。