网络编程
位置:首页>> 网络编程>> php编程>> 简单的PHP缓存设计实现代码

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

  发布时间:2023-10-25 19:58:08 

标签:PHP缓存设计

<?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()));
}
?>
0
投稿

猜你喜欢

手机版 网络编程 asp之家 www.aspxhome.com