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

yipeiwu_com6年前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()));
}
?>

相关文章

解决FastCGI 进程超过了配置的活动超时时限的问题

解决FastCGI 进程超过了配置的活动超时时限的问题

近日,需要满足测试需求,进行大数据并发测试时,报出【HTTP 错误 500.0 - Internal Server Error E:\PHP\php-cgi.exe - FastCGI...

解析Linux下Varnish缓存的配置优化

Varnish是一款高性能的开源HTTP加速器,挪威最大的在线报纸 Verdens Gang 使用3台Varnish代替了原来的12台Squid,性能比以前更好。但与老牌的squid相比...

php中的登陆login

login <?php require "../include/DBClass.php"; $username=$_POST['UserName']; $password...

PHP实现使用DOM将XML数据存入数组的方法示例

本文实例讲述了PHP实现使用DOM将XML数据存入数组的方法。分享给大家供大家参考,具体如下: <?php $doc = new DOMDocument('1.0','...

php 删除一维数组中某一个值元素的操作方法

1. 自己写for循环 从array里去掉$tmp这个元素的值 <?php $tmp = '324'; $arr = array( '0' => '321', '...