简单的PHP缓存设计实现代码
时间:2023-10-25 19:58:08
<?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缓存设计
![](/images/zang.png)
![](/images/jiucuo.png)
猜你喜欢
Python实现一个简单的递归下降分析器
2022-10-05 16:23:13
Python3自动签到 定时任务 判断节假日的实例
2022-11-15 15:48:48
小议javascript设计模式
2009-10-09 13:31:00
mac下安装mysql忘记密码的修改方法
2024-01-25 17:34:01
Python爬虫通过替换http request header来欺骗浏览器实现登录功能
2021-04-05 21:55:26
![](https://img.aspxhome.com/file/2023/9/102939_0s.png)
mysql load data infile 的用法(40w数据 用了3-5秒导进mysql)
2024-01-19 00:24:22
设置密码保护的SqlServer数据库备份文件与恢复文件的方法
2011-11-03 16:55:30
原生JS实现匀速图片轮播动画
2024-06-07 15:28:15
![](https://img.aspxhome.com/file/2023/9/122589_0s.jpg)
python3处理含有中文的url方法
2021-04-10 02:42:45
![](https://img.aspxhome.com/file/2023/8/92318_0s.jpg)
python使用for循环和海龟绘图实现漂亮螺旋线
2023-08-01 10:38:57
![](https://img.aspxhome.com/file/2023/5/90425_0s.jpg)
ajax取消挂起请求的处理方法
2023-11-20 23:41:53
SQLServer触发器创建、删除、修改、查看示例代码
2024-01-22 16:33:03
MySQL日期数据类型、时间类型使用总结
2024-01-27 09:46:51
vscode的几项基本配置详解
2022-05-13 23:28:29
![](https://img.aspxhome.com/file/2023/8/117528_0s.png)
go redis实现滑动窗口限流的方式(redis版)
2024-02-02 18:04:27
sql server中通过查询分析器实现数据库的备份与恢复方法分享
2012-05-22 18:41:58
巧用局部变量提升javascript性能
2024-04-18 09:33:19
Python数据分析之使用scikit-learn构建模型
2023-11-10 23:19:10
![](https://img.aspxhome.com/file/2023/5/64365_0s.jpg)
python time()的实例用法
2022-01-09 02:33:02
sqlserver2005 TSql新功能学习总结(数据类型篇)
2024-01-28 10:46:07