题目:memcache配置:host:localhost;port:11211; memcache key:uid_1、uid_2、uid_3、uid_4、uid_5、uid_6、uid_7、uid_8、uid_9、uid_10 写一段代码,请以效率最高的方式查询出上述10个key的数据(需写出从连接memcache开始到结束的完整过程)
具体代码: [PHP] 纯文本查看 复制代码 <?php
$host='Localhost';
$port=11211;
$mem=new Memcache();
$mem->connect($host,$port);
$items=$mem->getExtendedStats (‘items’);
$items=$items[$host,$port]['items'];
foreach($items as $key=>$values){
$number='uid_'.$key;
$str=$mem->getExtendedStats ("cachedump",$number,10);
$line=$str["$host:$port"];
if( is_array($line) && count($line)>0){
foreach($line as $key=>$value){
$mem->get($key);
}
}
}
?>
|