...
-
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']."
";
- }
- }
- }
复制代码
|
应用于, Redis, mysql
本主题由 小贝 于 2015-11-12 08:43 移动