我有以下代码来缓存xml输出。问题是它将xml对象缓存到memcache然后我访问memcache中的xml对象我得到错误:
“警告:Memcache :: get()[memcache.get]:节点不再存在于...”
$cachekey = md5($url);
$memcache = new Memcache;
$memcache->connect('localhost', 11211) or die ("Could not connect");
$data = $memcache->get($cachekey);
if($data === FALSE)
{
$data = simplexml_load_file($url);
$memcache->set($cachekey,$data,FALSE,900) or die ("Failed to create cache set");
}
我该如何解决这个问题?谢谢!
答案 0 :(得分:0)
好的,我让它工作,而不是从我将其下载到字符串中的url加载xml文件,然后从字符串加载xml:
$cachekey = md5($url);
$memcache = new Memcache;
$memcache->connect('localhost', 11211) or die ("Could not connect");
$data = $memcache->get($cachekey);
if($data === FALSE)
{
$data = file_get_contents($url);
$memcache->set($cachekey,$data,FALSE,900) or die ("Failed to create cache set");
}
$xmldata = simplexml_load_string($data);