function Environment::setCache
Sets the current cache implementation.
Parameters
CacheInterface|string|false $cache A Twig\Cache\CacheInterface implementation,: an absolute path to the compiled templates, or false to disable cache
1 call to Environment::setCache()
- Environment::__construct in vendor/
twig/ twig/ src/ Environment.php - Constructor.
File
-
vendor/
twig/ twig/ src/ Environment.php, line 271
Class
- Environment
- Stores the Twig configuration and renders templates.
Namespace
TwigCode
public function setCache($cache) {
if (\is_string($cache)) {
$this->originalCache = $cache;
$this->cache = new FilesystemCache($cache, $this->autoReload ? FilesystemCache::FORCE_BYTECODE_INVALIDATION : 0);
}
elseif (false === $cache) {
$this->originalCache = $cache;
$this->cache = new NullCache();
}
elseif ($cache instanceof CacheInterface) {
$this->originalCache = $this->cache = $cache;
}
else {
throw new \LogicException('Cache can only be a string, false, or a \\Twig\\Cache\\CacheInterface implementation.');
}
}