更多>
最新下载
24小时阅读排行榜
- 1 Javascript如何操作iframe_如何进行跨域通信?
- 2 php声明一个数组步骤_php数组定义基本语法详解【解析】
- 3 javascript中的WebSocket是什么_如何实现实时通信
- 4 Javascript对象如何创建_原型和类有什么区别?
- 5 如何添加html文档_创建并添加新的HTML文档到项目【创建】
- 6 javascript的本地存储有哪些方案_localStorage和sessionStorage有何区别
- 7 html5如何引入图标_HTML5引入图标库与自定义图标方法【图标引入】
- 8 html5如何绘制爱心_HTML5绘制爱心图形与Canvas技巧【教程】
- 9 mysql集群如何进行扩容_mysql水平扩展方法
- 10 SQL数据字典如何维护_提升团队协作效率方法【教程】
- 11 Python成员运算符用法详解_in与notin实战解析【技巧】
- 12 javascript的性能如何优化_有哪些最佳实践?
- 13 如何用Python开发网络监听工具_网络数据捕获核心逻辑【技巧】
- 14 如何在mysql中使用having条件_mysql having条件用法
- 15 LinuxShell脚本如何复用_函数库设计实践【指导】
更多>
最新教程
-
- Node.js 教程
- 13941 2025-08-28
-
- CSS3 教程
- 1540176 2025-08-27
-
- Rust 教程
- 21641 2025-08-27
-
- Vue 教程
- 24183 2025-08-22
-
- PostgreSQL 教程
- 20930 2025-08-21
-
- Git 教程
- 8233 2025-08-21
下载首页 / 类库下载 / 其它类库
<?php
class CacheLayer{
protected $root = "";
protected $cache = "";
protected $key = "";
protected $life = 0;
public function __construct($key, $root = "/cachelayer"){
$this->root = $_SERVER["DOCUMENT_ROOT"].$root;
$this->key = $key;
}
public function expired($life_span){
$this->life = $life_span;
$file = $this->root."/".$this->key.".cachelayer";
if(is_file($file)){
$mtime = filemtime($file);
return (time() >= ($mtime + $this->life));
}else{
return true;
}
}
public function put($content){
$file = $this->root."/".$this->key.".cachelayer";
if(!is_dir(dirname($this->root))){
return false;
}
$this->delete();
$content = json_encode($content);
return (bool)file_put_contents($file, $content);
}
public function get(){
$file = $this->root."/".$this->key.".cachelayer";
if(is_file($file)){
return json_decode(file_get_contents($file), true);
}
return array();
}
public function delete(){
$file = $this->root."/".$this->key.".cachelayer";
if(is_file($file)){
unlink($file);
return true;
}
return false;
}
}
?>这是一份很好用的PHP缓存类库,需要的朋友可以下载使用,可以通过文件缓存,大大缓解数据库的压力
本站所有资源都是由网友投搞发布,或转载各大下载站,请自行检测软件的完整性!本站所有资源仅供学习与参考,请勿用于商业用途,否则产生的一切后果将由您自己承担!如有侵权请联系我们删除下架,联系方式:admin@php.cn
