memcache存储mysql select结果
<?php $mem=new Memcache; $mem->connect("localhost",11211); $sql="select * from uc_members"; $key=md5($sql); $data=$mem->get($key); if(!$data){ $mysqli=new mysqli("localhost","root","","ucenter"); $result=$mysqli->query($sql); $data=array(); while ($row=$result->Fetch_assoc()) { $data[]=$row; } $result->free(); $mysqli->close(); $mem->set($key,$data,MEMCACHE_COMPRESSED,3600); echo $sql; } echo '<pre>'; print_r($data); echo '</pre>'; $mem->close(); ?>
相关推荐
苏康申 2020-11-13
vitasfly 2020-11-12
专注前端开发 2020-10-21
oraclemch 2020-11-06
liuyang000 2020-09-25
FellowYourHeart 2020-10-05
赵继业 2020-08-17
whyname 2020-08-16
Seandba 2020-08-16
dbasunny 2020-08-16
拼命工作好好玩 2020-08-15
langyue 2020-08-15
写程序的赵童鞋 2020-08-03
Accpcjg 2020-08-02
tydldd 2020-07-30
好记忆也需烂 2020-07-28
jianghero 2020-07-28