cache_id = md5("private_sales_".$cache_prefix."_".$d->format('Ymd')); $this->max_filemtime = $d->getTimestamp() - $lifetime; $this->path_cache_file = __DIR__.'/../cache/'.$this->cache_id; $this->smarty = $smarty; } function __destruct() { if (!empty($this->template_path && $this->smarty)) { file_put_contents($this->path_cache_file, $this->smarty->fetch($this->template_path)); } } function isCached($template_path) { if (file_exists($this->path_cache_file) && filemtime($this->path_cache_file) > $this->max_filemtime) { return true; } $this->template_path = $template_path; return false; } function getCache() { return file_get_contents($this->path_cache_file); } static function clearAll() { foreach(glob(__DIR__.'/../cache/*') as $path_file) { if (preg_match('/index\.php$/', $path_file)===1) { continue; } @unlink($path_file); } } }