zoukankan      html  css  js  c++  java
  • 获取memcache中所有数据

    
    
    remap_table方法是用的一个框架写的:

    $gvs = $this->pageObj->get;是获取通过get方式传递过来的数据;

    $mem = $this->pageObj->memcache;是实例化一个memcache对象;
    其他的基本上就没有框架的痕迹了

    protected
    function remap_table($sql) { $gvs = $this->pageObj->get; $host="127.0.0.1"; $port="11211"; // $mem = new Memcache(); // $link = @$mem->connect($host, $port); // //判断是否连接成功 // if(!$link) // return 'memcache服务器连接失败'; $mem = $this->pageObj->memcache; //判断是否属于搜索 if($gvs->key != ''){ //模糊查询 $findIndex = $gvs->key; $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){ $datas = array(); $num = 0; foreach($line as $key=>$value){ if(strpos($key, $findIndex) === false){ continue; } $datas[$num]['id'] = $num+1; $datas[$num]["k"] = $key; $info = $mem->get($key); if(strlen($info)>150){ $info = substr($info, 0, 150); $info = $info.'...'; } $datas[$num]["val"] = $info; $num++; } } return $datas; } }else{ $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){ $datas = array(); $num = 0; foreach($line as $key=>$value){ $datas[$num]['id'] = $num+1; $datas[$num]["key"] = $key; $info = $mem->get($key); if(strlen($info)>150){ $info = substr($info, 0, 150); $info = $info.'...'; } $datas[$num]["val"] = $info; $num++; } } //$datas[100] = array("key"=>111,"val"=>222); //$datas[101] = array("key"=>'13q1',"val"=>2322); // print_r($datas); return $datas; } } }
  • 相关阅读:
    优先队列
    Problem W UVA 662 二十三 Fast Food
    UVA 607 二十二 Scheduling Lectures
    UVA 590 二十一 Always on the run
    UVA 442 二十 Matrix Chain Multiplication
    UVA 437 十九 The Tower of Babylon
    UVA 10254 十八 The Priest Mathematician
    UVA 10453 十七 Make Palindrome
    UVA 10163 十六 Storage Keepers
    UVA 1252 十五 Twenty Questions
  • 原文地址:https://www.cnblogs.com/wxdblog/p/6844272.html
Copyright © 2011-2022 走看看