Enable or disable the cache

@param bool   $cache True or false.
@param string $path  The cache path
@param bool   $reload
@return TemplateEngineFactory
494658
public function setCache($cache, $path, $reload = true)
    {
        $this->_cache        = (bool) $cache;
        $this->_cache_path   = $path;
        $this->_caceh_reload = $reload;

        return $this;
    }
46402
public function initCache(Cache $cache, $enableCache = false)
    {
        $this->cache          = $cache;
        $this->isCacheEnabled = $enableCache;

        if ($enableCache) {
            $this->cache->enable();
        } else {
            $this->cache->disable();
        }

        return $this;
    }
212070
public function setCache(Mustache_Cache $cache)
    {
        if (isset($this->logger) && $cache->getLogger() === null) {
            $cache->setLogger($this->getLogger());
        }

        $this->cache = $cache;
    }
1263668
public function find( $key, $disableLateLoading = null, $cache = true )
    {

        // $disableLateLoading default value management
        if( !is_bool( $disableLateLoading ) ) {
            $disableLateLoading = false;
        }

        // have we switched off the multiton?
        if( !$cache ) {
            return parent::find( $key, $disableLateLoading );
        }

        // determine the multitonKey
        if( is_null( $key ) ) {
            return null;
        } elseif( is_scalar( $key ) ) {
            $multitonKey = $key;
        } elseif( is_array( $key ) ) {
            $multitonKey = call_user_func( "{$this->entityClass}::keyGet", $key );
        } else {
            return null;
        }

        // do we have this?
        if( !isset( $this->instancesPersisted[$multitonKey] ) ) {

            $obj = parent::find( $key, $disableLateLoading );

            // not got anything?
            if( !$obj ) {
                return null;
            }

            $this->garbageCollect();
            $this->instancesPersisted[$multitonKey] = $obj;

        // disable late loading
        } elseif( $disableLateLoading ) {

            $this->instancesPersisted[$multitonKey]->load();

        }

        return $this->instancesPersisted[$multitonKey];

    }
74435
public function enableCache($enabled = true)
    {
        if ($enabled && extension_loaded('apcu')) {
            $this->_cache = true;
        } else {
            $this->_cache = false;
        }

        return $this->_cache;
    }
1345296
public static function instance($reload = false) {

        if (HttpRequest::$instance == null || $reload) {
            HttpRequest::$instance = new HttpRequest ();
        }


        return HttpRequest::$instance;
    }
1218172
protected function find_file($cache = true)
	{
		if (($this->file[0] === '/' or (isset($this->file[1]) and $this->file[1] === ':')) and is_file($this->file))
		{
			$paths = array($this->file);
		}
		else
		{
			$paths = array_merge(
				\Finder::search('config/'.\Fuel::$env, $this->file, $this->ext, true, $cache),
				\Finder::search('config', $this->file, $this->ext, true, $cache)
			);
		}

		if (empty($paths))
		{
			throw new \ConfigException(sprintf('File "%s" does not exist.', $this->file));
		}

		return array_reverse($paths);
	}
820358
public function regenerate($cache = true)
    {
        $finder = new DocumentationManifestFileFinder();
        $finder->setOptions(
            array(
            'dir_callback' => array($this, 'handleFolder'),
            'file_callback'  => array($this, 'handleFile')
            )
        );

        $this->redirects = array();
        foreach ($this->getEntities() as $entity) {
            $this->entity = $entity;

            $this->handleFolder('', $this->entity->getPath(), 0);
            $finder->find($this->entity->getPath());
        }

        // groupds
        $grouped = array();

        foreach ($this->pages as $url => $page) {
            if (!isset($grouped[$page['entitypath']])) {
                $grouped[$page['entitypath']] = array();
            }

            $grouped[$page['entitypath']][$url] = $page;
        }

        $this->pages = array();

        foreach ($grouped as $entity) {
            uasort(
                $entity,
                function ($a, $b) {
                    // ensure parent directories are first
                    $a['filepath'] = str_replace('index.md', '', $a['filepath']);
                    $b['filepath'] = str_replace('index.md', '', $b['filepath']);

                    if (strpos($b['filepath'], $a['filepath']) === 0) {
                        return -1;
                    }

                    if ($a['filepath'] == $b['filepath']) {
                        return 0;
                    }

                    return ($a['filepath'] < $b['filepath']) ? -1 : 1;
                }
            );

            $this->pages = array_merge($this->pages, $entity);
        }

        if ($cache) {
            $this->cache->save(
                array(
                    'pages' => $this->pages,
                    'redirects' => $this->redirects
                ),
                $this->cacheKey
            );
        }

        $this->inited = true;
    }
988709
public function setCachePath($cachePath = NULL)
    {
        $this->cachePath = $cachePath;
        $this->debug->debug(__FUNCTION__, 'setCachePath: ', $this->cachePath);
    }
1249024
public function setCache(\Doctrine\Common\Cache\Cache $cache) {
		$this->cache = $cache;
		return $this;
	}
44421
private function isCacheUpToDate(&$path, $input = null)
    {
        if (!$input) {
            $compiler = $this->getRenderer()->getCompiler();
            $input = $compiler->resolve($path);
            $path = $this->getCachePath(
                ($this->getOption('keep_base_name') ? basename($path) : '').
                $this->hashPrint($input)
            );

            // If up_to_date_check never refresh the cache
            if (!$this->getOption('up_to_date_check')) {
                return true;
            }

            // If there is no cache file, create it
            if (!file_exists($path)) {
                return false;
            }

            // Else check the main input path and all imported paths in the template
            return !$this->hasExpiredImport($input, $path);
        }

        $path = $this->getCachePath($this->hashPrint($input));

        // Do not re-parse file if the same hash exists
        return file_exists($path);
    }
851488
public function init(string $templatesPath, string $cachePath = null) : TemplateLoaderInterface
    {

        $this->fs = new Filesystem($templatesPath);
        $this->loaders = [];

        foreach (self::$providers as $ext => $provider) {
            $this->loaders[$ext] = new $provider();
            $this->loaders[$ext]->init($templatesPath, $cachePath);
        }

        return $this;
    }
1066264
def _load_cache(self):
        """"""
        if not self._disable_cache:
            if os.path.exists(self._cache_path):
                _LOGGER.debug("Cache found at: %s", self._cache_path)
                if os.path.getsize(self._cache_path) > 0:
                    loaded_cache = UTILS.load_cache(self._cache_path)
                    UTILS.update(self._cache, loaded_cache)
                else:
                    _LOGGER.debug("Cache file is empty.  Removing it.")
                    os.remove(self._cache_path)

        self._save_cache()
422244
private function loadFromCache($path)
    {
        if ($this->getCache()) {
            return $this->getCache()->read(self::CACHE_KEY . md5($path));
        }

        return false;
    }
1123045
static function canRestoreCache( $key, $timestamp, $templateFilepath )
    {
        if ( !eZTemplateTreeCache::isCacheEnabled() )
            return false;

        $templateCache =& eZTemplateTreeCache::cacheTable();
        $key = eZTemplateTreeCache::internalKey( $key );
        if ( isset( $templateCache[$key] ) )
        {
            return false;
        }
        $cacheFileName = eZTemplateTreeCache::treeCacheFilename( $key, $templateFilepath );

        $php = new eZPHPCreator( eZTemplateTreeCache::cacheDirectory(), $cacheFileName );
        return $php->canRestore( $timestamp );
    }
813279
public function load( $reset = true )
    {
        if ( $this->UseCache )
        {
            $this->loadCache( $reset );
        }
        else
        {
            $this->parse( false, false, $reset );
        }
    }
545606
private function require_file($path) {
		$path = realpath($path);
		if (file_exists($path)) {
			require_once $path;

			// Opcache compilation
			$opcache_enabled = ini_get('opcache.enable');
			$opcache_cli_enabled = ini_get('opcache.enable_cli');
			if ( (php_sapi_name() == 'cli' and $opcache_cli_enabled) or (php_sapi_name() != 'cli' and $opcache_enabled)) {
				if (function_exists('opcache_is_script_cached') and function_exists('opcache_compile_file')) {
					if (!opcache_is_script_cached($path)) {
						// We have noticed OPcache sometimes yields a warning when compiling a file,
						// while that exact same file compiled just fine moments earlier. Worse, it
						// seems the OPcache for said file becomes corrupt somehow. This might
						// be a bug somewhere. We'll try to work around this issue by suppressing the
						// warning and explicitly invalidate the cache for the file if compilation fails.
						if (@opcache_compile_file($path) === false) {
							opcache_invalidate($path, true);
						}
					}
				}
			}

			return true;
		} else {
			throw new \Exception('File not found');
		}
	}