|
復(fù)制代碼 代碼如下:
**
* @說(shuō)明: 文件緩存輸出
* @參數(shù): $cachefile => cache文件(絕對(duì)路徑)
* @參數(shù): $pertime => 緩存輸出的間隔時(shí)間
* @參數(shù): $sql => sql語(yǔ)句
* @參數(shù): $templatefile => 模板文件名稱(絕對(duì)路徑)
* www.php100.com 來(lái)自
**/
function __cache($cachefile,$pertime,$sql,$templatefile) {
global $db;
if(time() - @filemtime($cachefile) >= $pertime) {
$query = $db->query($sql);
while($r=$db->fetch($query)) {
$cachelist[] = $r;
}
include $templatefile.'.php';
$cacheserialize = serialize($cachelist);
file_put_contents($cachefile,$cacheserialize);
}else{
$cachelist = unserialize(file_get_contents($cachefile));
include $templatefile.'.php';
}
}
php技術(shù):php 緩存函數(shù)代碼,轉(zhuǎn)載需保留來(lái)源!
鄭重聲明:本文版權(quán)歸原作者所有,轉(zhuǎn)載文章僅為傳播更多信息之目的,如作者信息標(biāo)記有誤,請(qǐng)第一時(shí)間聯(lián)系我們修改或刪除,多謝。