@param      $tpl
@param null $cacheId
@param null $compileId

@return bool
167446
public function is_cached($tpl, $cacheId = null, $compileId = null)
    {
        return $this->isCached($this->makeTemplate($tpl, $cacheId, $compileId));
    }
683582
public function clear($cache_id, $options = array())
    {
        $result = null;
        $options += array('pattern' => '.cache');
        $this->hook->attach('cache.clear.before', $cache_id, $options, $result, $this);

        if (isset($result)) {
            return $result;
        }

        $result = true;

        if ($cache_id === null) {
            array_map('unlink', glob(GC_DIR_CACHE . '/*.cache'));
            gplcart_static_clear();
        } else {

            if (is_array($cache_id)) {
                $cache_id = gplcart_array_hash($cache_id);
            }

            array_map('unlink', glob(GC_DIR_CACHE . "/$cache_id{$options['pattern']}"));
            gplcart_static_clear($cache_id);
        }

        $this->hook->attach('cache.clear.after', $cache_id, $options, $result, $this);
        return (bool) $result;
    }
81633
public function hasItem($cacheId): bool
    {
        $path = $this->keyPath($cacheId);

        return FileUtils::exists($path);
    }
1347740
public function process(Smarty_Internal_Template $_template, Smarty_Template_Cached $cached = null)
    {
        /** @var Smarty_Internal_Template $_smarty_tpl
         * used in included file
         */
        $_smarty_tpl = $_template;

        return @include $_template->cached->filepath;
    }
706927
protected function from_cache($cache_id)
	{
		$cache_id = md5($cache_id);
		if (array_key_exists($cache_id, $this->cached_paths))
		{
			return $this->cached_paths[$cache_id];
		}

		return false;
	}
1083791
private function checkCacheValid( $cacheFile )
	{
		if ( file_exists( $cacheFile ) && ( filemtime( $cacheFile ) >  filemtime( $this->filePath ) ) )
		{
			return true;
		}

		return false;
	}
170800
function fetch($resource_name, $cache_id = null, $compile_id = null, $display = false)
	{
		static $_cache_info = array();

		$_smarty_old_error_level = $this->debugging ? error_reporting() : error_reporting(isset($this->error_reporting)
		? $this->error_reporting : error_reporting() & ~E_NOTICE);

		if (!$this->debugging && $this->debugging_ctrl == 'URL') {
			$_query_string = $this->request_use_auto_globals ? $_SERVER['QUERY_STRING'] : $GLOBALS['HTTP_SERVER_VARS']['QUERY_STRING'];
			if (@strstr($_query_string, $this->_smarty_debug_id)) {
				if (@strstr($_query_string, $this->_smarty_debug_id . '=on')) {
					// enable debugging for this browser session
					@setcookie('SMARTY_DEBUG', true);
					$this->debugging = true;
				} elseif (@strstr($_query_string, $this->_smarty_debug_id . '=off')) {
					// disable debugging for this browser session
					@setcookie('SMARTY_DEBUG', false);
					$this->debugging = false;
				} else {
					// enable debugging for this page
					$this->debugging = true;
				}
			} else {
				$this->debugging = (bool)($this->request_use_auto_globals ? @$_COOKIE['SMARTY_DEBUG'] : @$GLOBALS['HTTP_COOKIE_VARS']['SMARTY_DEBUG']);
			}
		}

		if ($this->debugging) {
			// capture time for debugging info
			$_params = array();
			require_once(SMARTY_CORE_DIR . 'core.get_microtime.php');
			$_debug_start_time = smarty_core_get_microtime($_params, $this);
			$this->_smarty_debug_info[] = array('type'      => 'template',
                                                'filename'  => $resource_name,
                                                'depth'     => 0);
			$_included_tpls_idx = count($this->_smarty_debug_info) - 1;
		}

		if (!isset($compile_id)) {
			$compile_id = $this->compile_id;
		}

		$this->_compile_id = $compile_id;
		$this->_inclusion_depth = 0;

		if ($this->caching) {
			// save old cache_info, initialize cache_info
			array_push($_cache_info, $this->_cache_info);
			$this->_cache_info = array();
			$_params = array(
                'tpl_file' => $resource_name,
                'cache_id' => $cache_id,
                'compile_id' => $compile_id,
                'results' => null
			);
			require_once(SMARTY_CORE_DIR . 'core.read_cache_file.php');
			if (smarty_core_read_cache_file($_params, $this)) {
				$_smarty_results = $_params['results'];
				if (!empty($this->_cache_info['insert_tags'])) {
					$_params = array('plugins' => $this->_cache_info['insert_tags']);
					require_once(SMARTY_CORE_DIR . 'core.load_plugins.php');
					smarty_core_load_plugins($_params, $this);
					$_params = array('results' => $_smarty_results);
					require_once(SMARTY_CORE_DIR . 'core.process_cached_inserts.php');
					$_smarty_results = smarty_core_process_cached_inserts($_params, $this);
				}
				if (!empty($this->_cache_info['cache_serials'])) {
					$_params = array('results' => $_smarty_results);
					require_once(SMARTY_CORE_DIR . 'core.process_compiled_include.php');
					$_smarty_results = smarty_core_process_compiled_include($_params, $this);
				}


				if ($display) {
					if ($this->debugging)
					{
						// capture time for debugging info
						$_params = array();
						require_once(SMARTY_CORE_DIR . 'core.get_microtime.php');
						$this->_smarty_debug_info[$_included_tpls_idx]['exec_time'] = smarty_core_get_microtime($_params, $this) - $_debug_start_time;
						require_once(SMARTY_CORE_DIR . 'core.display_debug_console.php');
						$_smarty_results .= smarty_core_display_debug_console($_params, $this);
					}
					if ($this->cache_modified_check) {
						$_server_vars = ($this->request_use_auto_globals) ? $_SERVER : $GLOBALS['HTTP_SERVER_VARS'];
						$_last_modified_date = @substr($_server_vars['HTTP_IF_MODIFIED_SINCE'], 0, strpos($_server_vars['HTTP_IF_MODIFIED_SINCE'], 'GMT') + 3);
						$_gmt_mtime = gmdate('D, d M Y H:i:s', $this->_cache_info['timestamp']).' GMT';
						if (@count($this->_cache_info['insert_tags']) == 0
						&& !$this->_cache_serials
						&& $_gmt_mtime == $_last_modified_date) {
							if (php_sapi_name()=='cgi')
							header('Status: 304 Not Modified');
							else
							header('HTTP/1.1 304 Not Modified');

						} else {
							header('Last-Modified: '.$_gmt_mtime);
							echo $_smarty_results;
						}
					} else {
						echo $_smarty_results;
					}
					error_reporting($_smarty_old_error_level);
					// restore initial cache_info
					$this->_cache_info = array_pop($_cache_info);
					return true;
				} else {
					error_reporting($_smarty_old_error_level);
					// restore initial cache_info
					$this->_cache_info = array_pop($_cache_info);
					return $_smarty_results;
				}
			} else {
				$this->_cache_info['template'][$resource_name] = true;
				if ($this->cache_modified_check && $display) {
					header('Last-Modified: '.gmdate('D, d M Y H:i:s', time()).' GMT');
				}
			}
		}

		// load filters that are marked as autoload
		if (count($this->autoload_filters)) {
			foreach ($this->autoload_filters as $_filter_type => $_filters) {
				foreach ($_filters as $_filter) {
					$this->load_filter($_filter_type, $_filter);
				}
			}
		}

		$_smarty_compile_path = $this->_get_compile_path($resource_name);

		// if we just need to display the results, don't perform output
		// buffering - for speed
		$_cache_including = $this->_cache_including;
		$this->_cache_including = false;
		if ($display && !$this->caching && count($this->_plugins['outputfilter']) == 0) {
			if ($this->_is_compiled($resource_name, $_smarty_compile_path)
			|| $this->_compile_resource($resource_name, $_smarty_compile_path))
			{
				include($_smarty_compile_path);
			}
		} else {
			ob_start();
			if ($this->_is_compiled($resource_name, $_smarty_compile_path)
			|| $this->_compile_resource($resource_name, $_smarty_compile_path))
			{
				include($_smarty_compile_path);
			}
			$_smarty_results = ob_get_contents();
			ob_end_clean();

			foreach ((array)$this->_plugins['outputfilter'] as $_output_filter) {
				$_smarty_results = call_user_func_array($_output_filter[0], array($_smarty_results, &$this));
			}
		}

		if ($this->caching) {
			$_params = array('tpl_file' => $resource_name,
                        'cache_id' => $cache_id,
                        'compile_id' => $compile_id,
                        'results' => $_smarty_results);
			require_once(SMARTY_CORE_DIR . 'core.write_cache_file.php');
			smarty_core_write_cache_file($_params, $this);
			require_once(SMARTY_CORE_DIR . 'core.process_cached_inserts.php');
			$_smarty_results = smarty_core_process_cached_inserts($_params, $this);

			if ($this->_cache_serials) {
				// strip nocache-tags from output
				$_smarty_results = preg_replace('!(\{/?nocache\:[0-9a-f]{32}#\d+\})!s'
				,''
				,$_smarty_results);
			}
			// restore initial cache_info
			$this->_cache_info = array_pop($_cache_info);
		}
		$this->_cache_including = $_cache_including;

		if ($display) {
			if (isset($_smarty_results)) { echo $_smarty_results; }
			if ($this->debugging) {
				// capture time for debugging info
				$_params = array();
				require_once(SMARTY_CORE_DIR . 'core.get_microtime.php');
				$this->_smarty_debug_info[$_included_tpls_idx]['exec_time'] = (smarty_core_get_microtime($_params, $this) - $_debug_start_time);
				require_once(SMARTY_CORE_DIR . 'core.display_debug_console.php');
				echo smarty_core_display_debug_console($_params, $this);
			}
			error_reporting($_smarty_old_error_level);
			return;
		} else {
			error_reporting($_smarty_old_error_level);
			if (isset($_smarty_results)) { return $_smarty_results; }
		}
	}
583908
public function display($tpl, $data = array())
    {
        if ($this->isRending) {
            throw new RenderException('Display is called.');
        }

        $this->assign($data);

        echo $this->render($tpl, $data);

        return true;
    }
46339
public function cache($cache_key, $cache_ttl = 0) {
		if (!is_string($cache_key) || empty($cache_key))
			throw new \InvalidArgumentException("Cache key is not a valid string.");
		
		if (!is_integer($cache_ttl) || $cache_ttl < 0)
			throw new \InvalidArgumentException("Cache TTL is not a valid integer.");
	
		return $this->merge(['cache.key' => $cache_key, 'cache.ttl' => $cache_ttl]);
	}
933655
public function compile(File $file, File $cacheFile) {
        $this->file = $file;
        $content = $this->compileString($file->read());
        return $cacheFile->write($this->compileHeaders().$content) !== false;
    }
472942
function hasCompiledTemplate( $keyData, $uri, &$resourceData, $templatePath, &$extraParameters, $timestamp )
    {
        $key = $this->cacheKey( $keyData, $resourceData, $templatePath, $extraParameters );
        return eZTemplateCompiler::hasCompiledTemplate( $key, $timestamp, $resourceData );
    }
335834
function _compile_resource($resource_name, $compile_path)
	{

		$_params = array('resource_name' => $resource_name);
		if (!$this->_fetch_resource_info($_params)) {
			return false;
		}

		$_source_content = $_params['source_content'];
		$_cache_include    = substr($compile_path, 0, -4).'.inc';

		if ($this->_compile_source($resource_name, $_source_content, $_compiled_content, $_cache_include)) {
			// if a _cache_serial was set, we also have to write an include-file:
			if ($this->_cache_include_info) {
				require_once(SMARTY_CORE_DIR . 'core.write_compiled_include.php');
				smarty_core_write_compiled_include(array_merge($this->_cache_include_info, array('compiled_content'=>$_compiled_content, 'resource_name'=>$resource_name)),  $this);
			}

			$_params = array('compile_path'=>$compile_path, 'compiled_content' => $_compiled_content);
			require_once(SMARTY_CORE_DIR . 'core.write_compiled_resource.php');
			smarty_core_write_compiled_resource($_params, $this);

			return true;
		} else {
			return false;
		}

	}
71677
public function setItem($cacheId, $content)
    {
        $cacheId = $this->normalizeKey($cacheId);

        $this->map[$cacheId] = $this->compact($content);

        return true;
    }
462950
public function setItem($cacheId, $content)
    {
        $cacheId = $this->normalizeKey($cacheId);

        try {
            return $this->cache->store($cacheId, serialize($content));
        } catch (ezcBaseException $ex) {
            return false;
        }
    }
563018
private function compile($tplFile, $cacheFile, $type)
    {
        //取得模板内容
        //$template = file_get_contents($tplFile);
        $template = $this->getTplContent($tplFile, $type);

        //执行替换
        $template = preg_replace($this->pattern, $this->replacement, $template);

        if (!Cml::$debug) {
            /* 去除html空格与换行 */
            $find = ['~>\s+<~', '~>(\s+\n|\r)~'];
            $replace = ['><', '>'];
            $template = preg_replace($find, $replace, $template);
            $template = str_replace('?><?php', '', $template);
        }

        //添加 头信息
        $template = '<?php if (!class_exists(\'\Cml\View\')) die(\'Access Denied\');?>' . $template;

        if (!$cacheFile) {
            return $template;
        }

        //写入缓存文件
        $this->makePath($cacheFile);
        file_put_contents($cacheFile, $template, LOCK_EX);
        return true;
    }
389796
public function writeCachedContent(Smarty_Template_Cached $cached, Smarty_Internal_Template $_template, $content)
    {
        if ($_template->source->handler->recompiled || !($_template->caching == Smarty::CACHING_LIFETIME_CURRENT ||
                $_template->caching == Smarty::CACHING_LIFETIME_SAVED)
        ) {
            // don't write cache file
            return false;
        }
        $content = $_template->smarty->ext->_codeFrame->create($_template, $content, '', true);
        return $this->write($cached, $_template, $content);
    }
513142
function XTemplate(tpl, config) {
  var tplType = (typeof tpl);
  if (tplType !== 'string' && tplType !== 'function') {
    config = tpl;
    tpl = undefined;
  }
  config = this.config = util.merge(XTemplate.globalConfig, config);
  if (tplType === 'string') {
    try {
      tpl = this.compile(tpl, config.name);
    } catch (err) {
      this.compileError = err;
    }
  }
  XTemplateRuntime.call(this, tpl, config);
}