使用memcache获取节点在php和xml中不再存在


Getting node no longer exist in php and xml with memcache

我有以下缓存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");
}

我该怎么解决这个问题?谢谢

好的,我开始工作了,我没有从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);