memcached mysql操作

<?php
header("content-type:text/html;charset=GBK");
//页面数据缓存

//1.当前页面有没有缓存(memcache---data)
$mem = new Memcache;

$mem->connect("127.0.0.1",11211);

//$mem->set("data","lalala",0,5);

$re= $mem->get("data");


if(!$re){
//没缓存
//生成缓存 数据去数据\n

$link = new PDO("mysql:host=127.0.0.1;dbname=test","root","root");

$ob= $link->query("select * from jl_good");

$arr = $ob->fetchAll();

$mem->set("data",$arr,0,5);

print_r($mem->get("data"));
echo "1111111111111111111";
}else{
print_r($mem->get("data"));
}

$A=111;


?>

猜你喜欢

转载自www.cnblogs.com/oy123/p/9268555.html