<table cellspacing="0" cellpadding="0"><tr><td class="t_f" id="postmessage_57492"> <div class="blockcode"> <div id="code_nw0"><ol> <li><?php<li> header("Content-type:text/html;charset=utf-8");<li> error_reporting(0);<li> $redis=new Redis();<li> $redis->connect('localhost',6379);</li> <li> if($redis->exists("blog")){</li> <li> $b=$redis->get("blog");</li> <li> $rs=unserialize($b);</li> <li> foreach($rs as $res){</li> <li> echo $res['title']."<br/>";</li> <li> }</li> <li> }</li> <li> else{ </li> <li> $conn= mysql_connect("localhost","root","root");</li> <li> mysql_select_db("test");</li> <li> mysql_query("set names utf8");</li> <li> $sql="select * from blog";</li> <li> $result=mysql_query($sql);</li> <li> $rss=array();</li> <li> while($rs=mysql_fetch_assoc($result)){</li> <li> $rss[]=$rs;</li> <li> $redis->set("blog", serialize($rss));</li> <li> $b=$redis->get("blog");</li> <li> $rs=unserialize($b);</li> <li> foreach($rs as $res){</li> <li> echo $res['title']."<br/>";</li> <li> }</li> <li> }</li> <li> }</li> </ol></div> <em onclick="copycode($('code_nw0'));">复制代码</em> </div> <br> </td></tr></table> <div class="ptg mbm mtn"> Redis, mysql에 적용</div> <div class="modact">이 주제는 2015-11-12 08:43에 Xiaobei에 의해 이동되었습니다</div> <div id="comment_57492" class="cm"> </div> <div id="post_rate_div_57492"></div> <br><br>