我想知道使用什么函数来缓存提取的数据并仅在 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'");
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);
?>