更多>
最新下载
24小时阅读排行榜
- 1 豆包AI免费写作工具入口 豆包AI写作助手app登录官网
- 2 VSCode Emmet快捷键使用技巧
- 3 苹果手机如何恢复Safari书签
- 4 现代JavaScript模块化开发实践与演进
- 5 Python代码如何进行数据可视化 Python代码使用Matplotlib库的实战指南
- 6 如何查看mysql的日志
- 7 html语言如何列表_HTML列表(ul/ol/dl)创建与样式设置方法
- 8 京东外卖商家装修怎么操作?京东如何装修店铺
- 9 夸克AI搜索简体中文官网地址 夸克最新设置与入口指南
- 10 c++怎么用asan, tsan, ubsan进行运行时检查_C++三大运行时检测工具使用指南
- 11 mongodb如何查询不包含某个字符串
- 12 vscode如何同步工作区设置_vscode工作区设置同步方法与技巧
- 13 Java正则表达式:灵活控制字母、数字与特定分隔符的组合验证
- 14 Golang如何在并发场景下优化内存分配
- 15 vscode全局替换如何避免覆盖重要内容_vscode重要内容保护与全局替换技巧
更多>
最新教程
-
- Node.js 教程
- 7210 2025-08-28
-
- CSS3 教程
- 1020482 2025-08-27
-
- Rust 教程
- 11455 2025-08-27
-
- Vue 教程
- 13675 2025-08-22
-
- PostgreSQL 教程
- 10506 2025-08-21
-
- Git 教程
- 5085 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

