获取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;
}
}
}
获取memcache中所有数据的更多相关文章
- php获取数组中重复数据的两种方法
分享下php获取数组中重复数据的两种方法. 1,利用php提供的函数,array_unique和array_diff_assoc来实现 <?php function FetchRepeatMem ...
- 基于BootStrap的initupload()实现Excel上传和获取excel中的数据
简单说明:后边要做exl解析(还没做呢),所以先有一个excel的的上传以及获取excel中的数据,展示出来. 代码: //html代码 <div class="btn-group&q ...
- Springboot中使用自定义参数注解获取 token 中用户数据
使用自定义参数注解获取 token 中User数据 使用背景 在springboot项目开发中需要从token中获取用户信息时通常的方式要经历几个步骤 拦截器中截获token TokenUtil工具类 ...
- 使用 UEditor 编辑器获取数据库中的数据
在 ThinkPHP 3.2.2 中,使用 UEditor 编辑器获取数据库中保存的数据,可以使用 UEditor 自身提供的方法. 首先在视图模板中实例化编辑器,这是出现编辑器界面的必须的行为: & ...
- SharePoint 2010 获取列表中所有数据(包括文件夹内)的方法
转: http://blog.csdn.net/wangwenism/article/details/8751411 SharePoint的列表能存储文件以及文件夹,用户使用的时候,经常会建几个分类文 ...
- JSP中获取jstl中的数据
我们在编程JSP时,有时会须要訪问jstl中的数据,或者说是el表达式中的数据. 比方, <c:forEach varStatus="data1" var=" ...
- 获取ASPxGridView 中的数据(仅仅是获取;注意模板是如何获取的)
1.取得控件值 using System.Collections.Generic; //取得当前控件值的集合 直接寻找控件的ID List<object> keyValues = this ...
- Struts2获取Action中的数据
当我们用Struts2框架开发时,经常有要获取jsp页面的数据或者在jsp中获取后台传过来的数据(Action),那么怎么去获取自己想要的数据呢? 后台获取前端数据: 在java程序中生成要获取字段的 ...
- Vue 在beaforeCreate时获取data中的数据
众所周知,vue在beforecreate时期是获取不到data中的 数据的 但是通过一些方法可以实现在beforecreate时获取到data中的数据 暂时想到两种放发可以实现,vue在before ...
随机推荐
- luoguP2418 yyy loves OI IV
https://www.luogu.org/problemnew/show/P2418 暴力 DP 做这题只有 30 分 考虑用线段树优化这个 DP 先处理一下整个房间都膜拜一个人的情况,然后将 1 ...
- Python——selenium爬取斗鱼房间信息
from selenium import webdriver import os import json import time class Douyu: def __init__(self): # ...
- EOS 智能合约 plublic key 转换
在做一个EOS 的action接口时,定义如下: void setbplist(const account_name bp_name, const uint64_t bp_time, const ...
- 自动判断PC端、手机端跳往不同的域名JS实现代码
输入相同域名,在pc端和移动端会出现不同的页面效果,一种是用栅格系统实现自适应, 更多的是设计两套不同的模板和两个二级域名或者一个主域名和一个二级域名(就是有区别就可以了); js代码判断浏览器的用户 ...
- JSP使用Struts2标签库报错
JSP中使用<%@ taglib prefix="s" uri="/struts-tags" %>报错:Cannot find the tag li ...
- Python循环流程
1.for循环 计算1+2+3+……+100的和 count = 0 i = 1 for i in range(101): count+=i print(count) 前n项和公式为:Sn=n*a1+ ...
- js 获取 屏幕 可用高度...
document.documentElement.clientWidth 此方法适用于手机... document.documentElement.clientHeight (浏览器(手机或电脑)可用 ...
- 教你搭建SpringSecurity3框架(附源码)
源码下载地址:http://pan.baidu.com/s/1qWsgIg0 一.web.xml <?xml version="1.0" encoding="UTF ...
- [转] 配置文件解析利器-Config库
[From] https://blog.csdn.net/zero__007/article/details/51493851 Typesafe的Config库,纯Java写成.零外部依赖.代码精简. ...
- PIE SDK自定义滤波
1.算法功能简介 自定义滤波可以自由设置滤波模板,对数据进行处理,自定义滤波器的一般规则要求: ( 1) 滤波器的大小应该是奇数,这样它才有一个中心,例如 3x3, 5x5 或者 7x7.有中心了,也 ...