<?php
/* versionbeta:name
 * versionbeta:number
 * versionbeta:site
 * versionbeta:pubtime
 */
class cls_cache {
	//取缓存数据
	static function get($key , $path , $time = 6000000) {
		$dir = empty($time) ? KJ_DIR_DATA . "/cache/" : KJ_DIR_CACHE . "/data/";
		$filepath = $dir . $path . "/" . $key . ".php";
		if(!file_exists($filepath)) return null;
		if($time>0) $time = TIME - $time * 60;
		$arr_html=fun_file::get_file_perms($filepath);
		if(strtotime($arr_html["mtime"]) < $time ) return null;
		return include($filepath);
	}

	static function set($arr , $key , $path , $notime=false) {
		$dir = $notime ? KJ_DIR_DATA . "/cache/" : KJ_DIR_CACHE . "/data/";
		$filepath = $dir . $path . "/" . $key . ".php";
		$val = var_export($arr,true);
		$val = '<'.'?php'.chr(10).'return '.$val.";";
		$arr = fun_file::file_create($filepath , $val , 1);
		return $arr;
	}
}