map_dir.$this->map_name; if(file_exists($file_path)){ $time_format = "y-m-d h:i:s"; $create_file_time = date($time_format,filectime($file_path)); $now = date($time_format); //配置默认一天更新一次 $diff = QmHelper::dateTimeDiff($create_file_time,$now); if($diff[$this->unit] > $this->life_time){ $this->delete(); return false; } return $file_path; } return false; } /** * 加载map * @return bool|string */ public function loadMap(){ if($file_path = $this->hasMap()){ $content = file_get_contents($file_path); if(!isset($content) || empty($content)){ $this->delete(); return false; } return $content; } return false; } /** * 保存map * @param $value */ public function saveMap($value){ if($file_path = $this->hasMap()){ $this->delete(); }else{ $file_path = $this->map_dir.$this->map_name; } file_put_contents($file_path,$value); } /** * 删除 */ public function delete(){ $file_path = $this->map_dir.$this->map_name; if(file_exists($file_path) && is_writeable($file_path)){ unlink($file_path); } } }