首页 > Web开发 > 详细

简单的PHP缓存设计实现代码

时间:2016-01-22 12:19:45      阅读:155      评论:0      收藏:0      [点我收藏+]
复制代码 代码如下:

<?php
//本功能主要是利用文件修改时间函数filemtime与现在时间作减法判断是否更新内容。
$cahetime=2;//设置过期时间
$cahefile="cahe.txt";//读写文本

if(file_exists($cahefile) && time()-$cahetime< filemtime($cahefile)){

echo file_get_contents($cahefile);
}
else {
file_put_contents($cahefile,date("y-m-d H:i:s",time()));
}
?>

简单的PHP缓存设计实现代码

原文:http://www.jb51.net/article/28431.htm

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!