日期:2014-05-16 浏览次数:20799 次
<?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(); ?>