cache_time = (int) $cache_time; $this->cache_file = CACHE_PATH.'/'.$cache_name; } /** * Сохраняет кэш в файл * * @return boolean - сохранил или нет */ function save($data) { if ($this->cache_time != 0) { return (bool) file_put_contents($this->cache_file, $data); } return false; } /** * Достает кэш из файла * * @return string - содержимое кеша */ function load() { return file_get_contents($this->cache_file); } function reset() { @unlink($this->cache_file); } /** * Проверяет, закешированы ли данные с таким именем * * @return boolean - закеширован или нет */ function isCached() { if (! file_exists($this->cache_file)) { return false; } if ($this->cache_time > 0 && $this->cache_time + filemtime($this->cache_file) < TIME_NOW) { return false; } return true; } } ?>