<?php
/**
 * [UQcms System] Copyright uqcms.com
 * QQ: 2200631718
 * Author: gj.name
 * This is NOT a freeware
*/
 class file_cache { function __construct(){ $this->path = 'cache_dir/'; $this->cache_time = '1800'; } function get($key){ $file_url = $this->file_path($key); $status = @file_get_contents($file_url); if($status){ return $status; }else{ return false; } } function set($key,$value){ $file_url = $this->file_path($key); $result = $this->write_contents($file_url,$value); if($result){ return true; }else{ return false; } } function delete($key){ $file_url = $this->file_path($key); @unlink($file_url); return true; } function file_path($key){ $str = md5($key); $path_dir = ''; for($i=1;$i<3;$i++){ $path_dir .= substr($str,($i*2),2).'/'; } return $this->path.$path_dir.$str; } function write_contents($file_url,$value){ $fp = fopen($file_url,'w'); $result = fwrite($fp,$value); fclose($fp); if($result){ return true; }else{ return false; } } }