欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

php 緩存函數(shù)代碼

 更新時間:2008年08月27日 12:55:37   作者:  
簡單實用的緩存函數(shù)

復制代碼 代碼如下:

**
* @說明: 文件緩存輸出
* @參數(shù): $cachefile => cache文件(絕對路徑)
* @參數(shù): $pertime => 緩存輸出的間隔時間
* @參數(shù): $sql => sql語句
* @參數(shù): $templatefile => 模板文件名稱(絕對路徑)
* www.php100.com 來自
**/
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';
}
}

相關文章

最新評論