更多>
最新下载
24小时阅读排行榜
- 1 如何利用CSS3做出漂亮的渐变效果_制作流畅的背景渐变效果
- 2 C++虚函数有什么用 C++多态实现原理与代码演示【进阶】
- 3 Go语言如何编写表驱动测试_表驱动测试写法解析
- 4 Go语言命名规范有哪些_Golang基础编码规范说明
- 5 c++如何计算两个日期的间隔_c++时间戳计算方法【实战】
- 6 如何搭建mysql调试环境_mysql问题排查环境
- 7 mysql MyBatis是什么_mysql持久层框架讲解
- 8 css not 选择器可以组合使用吗_否定选择规则说明
- 9 Go反射为什么需要指针 Golang反射修改值原理说明
- 10 php实现班级通信录怎么导入mysql_php导入数据入库方法【步骤】
- 11 kali怎么挖php漏洞_用golismero整合扫描php多漏洞【技巧】
- 12 PowerShell如何从XML文件中导出数据到CSV
- 13 mysql面试为什么常问SQL执行流程_高频考点解析
- 14 c# 如何在高并发下保证数据库迁移(EF Core Migration)的安全性
- 15 C++ 怎么判断文件是否为空 C++ seekg与tellg检查文件大小代码【IO】
更多>
最新教程
-
- Node.js 教程
- 16322 2025-08-28
-
- CSS3 教程
- 1547008 2025-08-27
-
- Rust 教程
- 23437 2025-08-27
-
- Vue 教程
- 25873 2025-08-22
-
- PostgreSQL 教程
- 22375 2025-08-21
-
- Git 教程
- 9325 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
