本文整理汇总了PHP中Nette\Caching\Cache::release方法的典型用法代码示例。如果您正苦于以下问题:PHP Cache::release方法的具体用法?PHP Cache::release怎么用?PHP Cache::release使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Nette\Caching\Cache
的用法示例。
在下文中一共展示了Cache::release方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: render
/**
* Renders template to output.
* @return void
*/
public function render()
{
if ($this->file == NULL) {
// intentionally ==
throw new Nette\InvalidStateException("Template file name was not specified.");
}
$cache = new Caching\Cache($storage = $this->getCacheStorage(), 'Nette.FileTemplate');
if ($storage instanceof Caching\Storages\PhpFileStorage) {
$storage->hint = str_replace(dirname(dirname($this->file)), '', $this->file);
}
$cached = $compiled = $cache->load($this->file);
if ($compiled === NULL) {
try {
$compiled = "<?php\n\n// source file: {$this->file}\n\n?>" . $this->compile();
} catch (FilterException $e) {
$e->setSourceFile($this->file);
throw $e;
}
$cache->save($this->file, $compiled, array(Caching\Cache::FILES => $this->file, Caching\Cache::CONSTS => 'Nette\\Framework::REVISION'));
$cache->release();
$cached = $cache->load($this->file);
}
if ($cached !== NULL && $storage instanceof Caching\Storages\PhpFileStorage) {
Nette\Utils\LimitedScope::load($cached['file'], $this->getParams());
} else {
Nette\Utils\LimitedScope::evaluate($compiled, $this->getParams());
}
}
示例2: render
/**
* Renders template to output.
* @return void
*/
public function render()
{
if ($this->file == NULL) {
// intentionally ==
throw new \InvalidStateException("Template file name was not specified.");
}
$this->__set('template', $this);
$shortName = str_replace(dirname(dirname($this->file)), '', $this->file);
$cache = new Cache($this->getCacheStorage(), 'Nette.FileTemplate');
$key = trim(strtr($shortName, '\\/@', '.._'), '.') . '-' . md5($this->file);
$cached = $content = $cache[$key];
if ($content === NULL) {
if (!$this->getFilters()) {
$this->onPrepareFilters($this);
}
if (!$this->getFilters()) {
LimitedScope::load($this->file, $this->getParams());
return;
}
$content = $this->compile(file_get_contents($this->file), "file …{$shortName}");
$cache->save($key, $content, array(Cache::FILES => $this->file, Cache::EXPIRE => self::$cacheExpire, Cache::CONSTS => 'Nette\\Framework::REVISION'));
$cache->release();
$cached = $cache[$key];
}
if ($cached !== NULL && self::$cacheStorage instanceof TemplateCacheStorage) {
LimitedScope::load($cached['file'], $this->getParams());
fclose($cached['handle']);
} else {
LimitedScope::evaluate($content, $this->getParams());
}
}
示例3: render
/**
* Renders template to output.
* @return void
*/
public function render()
{
if ($this->file == NULL) {
// intentionally ==
throw new \InvalidStateException("Template file name was not specified.");
}
$this->__set('template', $this);
$cache = new Cache($storage = $this->getCacheStorage(), 'Nette.FileTemplate');
if ($storage instanceof TemplateCacheStorage) {
$storage->hint = str_replace(dirname(dirname($this->file)), '', $this->file);
}
$cached = $content = $cache[$this->file];
if ($content === NULL) {
try {
$content = $this->compile(file_get_contents($this->file));
$content = "<?php\n\n// source file: {$this->file}\n\n?>{$content}";
} catch (TemplateException $e) {
$e->setSourceFile($this->file);
throw $e;
}
$cache->save($this->file, $content, array(Cache::FILES => $this->file, Cache::CONSTS => 'Nette\\Framework::REVISION'));
$cache->release();
$cached = $cache[$this->file];
}
if ($cached !== NULL && $storage instanceof TemplateCacheStorage) {
LimitedScope::load($cached['file'], $this->getParams());
flock($cached['handle'], LOCK_UN);
fclose($cached['handle']);
} else {
LimitedScope::evaluate($content, $this->getParams());
}
}
示例4: render
/**
* Renders template to output.
* @return void
*/
public function render()
{
$cache = new Caching\Cache($storage = $this->getCacheStorage(), 'Nette.Template');
$cached = $compiled = $cache->load($this->source);
if ($compiled === NULL) {
$compiled = $this->compile();
$cache->save($this->source, $compiled, array(Caching\Cache::CONSTS => 'Nette\\Framework::REVISION'));
$cache->release();
$cached = $cache->load($this->source);
}
if ($cached !== NULL && $storage instanceof Caching\Storages\PhpFileStorage) {
Nette\Utils\LimitedScope::load($cached['file'], $this->getParams());
} else {
Nette\Utils\LimitedScope::evaluate($compiled, $this->getParams());
}
}