A股上市公司传智教育(股票代码 003032)旗下技术交流社区北京昌平校区

 找回密码
 加入黑马

QQ登录

只需一步,快速开始

题目: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); 
}
}
}
?>

0 个回复

您需要登录后才可以回帖 登录 | 加入黑马