/**
* @Description: File cache output
* @Parameter: $cachefile => cache file (absolute path)
* @Parameter: $pertime => Cache output interval
* @ Parameter: $sql => sql statement
* @Parameter: $templatefile => Template file name (absolute path)
**/
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;
}
}