用于从mysql表中提取数据的php脚本的缓存选项
我想知道使用什么函数来缓存拉取的数据,并在15-30分钟后刷新数据 下面是将数据从mysql拉到网站的php脚本用于从mysql表中提取数据的php脚本的缓存选项,php,html,mysql,caching,Php,Html,Mysql,Caching,我想知道使用什么函数来缓存拉取的数据,并在15-30分钟后刷新数据 下面是将数据从mysql拉到网站的php脚本 <?php include('mysql_connection.php'); $c = mysqlConnect(); $locale = $_GET['locale']; $last_bulletins_id = $_GET['bulletins_id']; sendQuery ("set character_set_results='utf8'"); sendQue
<?php
include('mysql_connection.php');
$c = mysqlConnect();
$locale = $_GET['locale'];
$last_bulletins_id = $_GET['bulletins_id'];
sendQuery ("set character_set_results='utf8'");
sendQuery ("set collation_connection='utf8_general_ci'");
if(strcmp($locale,"en") != 0)
$locale = "en";
$result = sendQuery("
SELECT bulletins.id, posted_date, message, name
FROM bulletins
LEFT JOIN players ON (bulletins.player_id = players.user_id)
WHERE bulletins.id > ".$last_bulletins_id." and locale = '".$locale."'
ORDER BY bulletins.id DESC
LIMIT 10");
echo '<table width=\"100%\">';
while($row = mysql_fetch_array($result, MYSQL_NUM))
{
echo '<tr><td width=\"100%\"><b>Date: </b>'.$row[1].'</td></tr>';
echo '<tr><td width=\"100%\"><b>Author: </b>'.$row[3].'</td></tr>';
echo '<tr><td width=\"100%\">'.nl2br($row[2]).'</td></tr>';
echo '<tr><td width=\"100%\"><hr style="height: 2px; border: none; background: #515151;"></td></tr>';
}
echo '</table>';
mysqlClose($c);
您应该将输出的数据写入缓存文件,并检查上次修改文件和加载缓存文件的时间,或者如果时间大于您设置的限制,则查询数据库并输出新结果。这些功能将方便您使用: