php 缓存函数代码
更新时间:2008年08月27日 12:55:37 作者:
简单实用的缓存函数
复制代码 代码如下:
**
* @说明: 文件缓存输出
* @参数: $cachefile => cache文件(绝对路径)
* @参数: $pertime => 缓存输出的间隔时间
* @参数: $sql => sql语句
* @参数: $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';
}
}
相关文章
巧用php中的array_filter()函数去掉多维空值的代码分享
在我们开发过程中,判断数组为空时你会想到什么方法呢?首先想到的应该是empty函数,不过直接用empty函数判断为空是不对的,因为当这个值是多维数的时候,empty结果是有值的2012-09-09Admin generator, filters and I18n
You need to modify your EntityFormFilter (where Entity is your object class - Article, Book, etc.).2011-10-10Apache实现Web Server负载均衡详解(不考虑Session版)
本篇文章是对使用Apache实现Web Server负载均衡的方法进行了详细的分析介绍,需要的朋友参考下(不考虑Session版)2013-07-07
最新评论