header("Content-type:text/html;charset=utf-8");
error_reporting(0);
$redis=new Redis();
$redis->connect('localhost',6379);
if($redis->exists("blog")){
$b=$redis->get("blog");
$rs=unserialize($b);
foreach($rs as $res){
echo $res['title']."
";
}
}
else{
$conn= mysql_connect("localhost","root","root");
mysql_select_db("test");
mysql_query("set names utf8");
$sql="select * from blog";
$result=mysql_query($sql);
$rss=array();
while($rs=mysql_fetch_assoc($result)){
$rss[]=$rs;
$redis->set("blog", serialize($rss));
$b=$redis->get("blog");
$rs=unserialize($b);
foreach($rs as $res){
echo $res['title']."
";
}
}
}