您当前的位置: 首页 > 学无止境 > 心得笔记 网站首页心得笔记
php获取memcached中所有键值对
发布时间:2017-06-15 17:43:24编辑:雪饮阅读()
function mFetchAll($host,$port){
$zArr=array();
$mem = new Memcache();
$mem->connect($host, $port);
$items = $mem->getExtendedStats('items');
$items = $items["$host:$port"]['items'];
foreach ($items as $key => $values) {
$number = $key;
$str = $mem->getExtendedStats("cachedump", $number, 0);
$line = $str["$host:$port"];
if (is_array($line) && count($line) > 0) {
foreach ($line as $key => $value) {
$tmpArr=array("key"=>$key,"val"=>$mem->get($key));
array_push($zArr,$tmpArr);
}
}
}
return $zArr;
}
只需要传递host和端口即可
关键字词:php,memcached,所有