php APP缓存
来源:互联网 发布:生死狙击矩阵视频 编辑:程序博客网 时间:2024/06/05 06:41
<?phpclass File{ private $_dir; const EXT='.text'; public function __construct(){ $this->_dir=dirname(__FILE__) .'/files/'; } public function cacheData($key,$value='',$cacheTime = 0){ $filename=$this->_dir.$key.self::EXT; if($value!==''){//将value值写入缓存 if(is_null($value)){ return @unlink($filename); } $dir=dirname($filename); if(!is_dir($dir)){ mkdir($dir,0777); } $cacheTime = sprintf('%011d',$cacheTime); return file_put_contents($filename,$cacheTime.json_encode($value)); } if(!is_file($filename)){ return false; }else{ $contents = file_get_contents($filename); $cacheTime = (int)substr($contents, 0,11); $value = substr($contents,11); if($cacheTime!=0&&($cacheTime + filemtime($filename) <time())){ unlink($filename); return false; } return json_decode($value,true); } }}
0 0
- php APP缓存
- php开发app接口之静态缓存
- php缓存
- PHP缓存
- PHP 缓存
- php缓存
- php缓存
- App缓存管理
- App缓存管理
- App缓存管理
- Android --- App缓存管理
- Android--App缓存管理
- Android--App缓存管理
- android App 缓存管理
- App缓存管理
- APP开发关于缓存
- android App缓存管理
- Android--App缓存管理
- mac下用scp命令实现本地文件与服务器Linux文件之间的相互传输
- vmware,virtualbox,kvm的区别
- 小波变换的相关
- iOS开发网络篇—监测网络状态
- iOS开发多线程-自定义NSOperation
- php APP缓存
- android Notification跳转 getIntent()问题
- C#导出DataTable数据到CSV文件中
- python爬虫环境搭建
- Android测试教程6--测试我们的Application
- php返回xml,json,array
- Machine Learning week 6 quiz: Machine Learning System Design
- Python常见第一个错误
- ABAP 提取或去除字符串中的中文字符(双字节字符)