コード例 #1
0
ファイル: DiscoveredReflection.php プロジェクト: krecek/nrsn
	public function setConnection(NConnection $connection)
	{
		$this->connection = $connection;
		if ($this->cacheStorage) {
			$this->cache = new NCache($this->cacheStorage, 'Nette.Database.' . md5($connection->getDsn()));
			$this->structure = $this->loadedStructure = ($tmp=$this->cache->load('structure')) ? $tmp : $this->structure;
		}
	}
コード例 #2
0
ファイル: CachedFilter.php プロジェクト: fabik/filter-stream
 /**
  * Filters the given file.
  * @param  string
  * @return string|NULL
  */
 public function processFile($path)
 {
     $data = $this->cache->load($path);
     if ($data === NULL) {
         $data = $this->filter->processFile($path);
         if ($data !== NULL) {
             $this->cache->save($path, $data, array(Cache::CONSTS => 'FilterStream\\FilterStream::REVISION', Cache::FILES => array($path)));
         }
     }
     return $data;
 }
コード例 #3
0
	public function setConnection(NConnection $connection)
	{
		$this->connection = $connection;
		if (!in_array($this->connection->getAttribute(PDO::ATTR_DRIVER_NAME), array('mysql'))) {
			throw new NotSupportedException("NDiscoveredReflections supports only mysql driver");
		}

		if ($this->cacheStorage) {
			$this->cache = new NCache($this->cacheStorage, 'Nette.Database.' . md5($connection->getDsn()));
			$this->structure = ($tmp=$this->cache->load('structure')) ? $tmp : $this->structure;
		}
	}
コード例 #4
0
ファイル: Template.php プロジェクト: krecek/nrsn
	/**
	 * Renders template to output.
	 * @return void
	 */
	public function render()
	{
		$cache = new NCache($storage = $this->getCacheStorage(), 'Nette.Template');
		$cached = $compiled = $cache->load($this->source);

		if ($compiled === NULL) {
			$compiled = $this->compile();
			$cache->save($this->source, $compiled, array(NCache::CONSTS => 'NFramework::REVISION'));
			$cached = $cache->load($this->source);
		}

		if ($cached !== NULL && $storage instanceof NPhpFileStorage) {
			NLimitedScope::load($cached['file'], $this->getParameters());
		} else {
			NLimitedScope::evaluate($compiled, $this->getParameters());
		}
	}
コード例 #5
0
ファイル: Selection.php プロジェクト: krecek/nrsn
	/**
	 * Loads cache of previous accessed columns and returns it.
	 * @internal
	 * @return array|false
	 */
	public function getPreviousAccessedColumns()
	{
		if ($this->cache && $this->previousAccessedColumns === NULL) {
			$this->accessedColumns = $this->previousAccessedColumns = $this->cache->load($this->getCacheKey());
		}

		return array_keys(array_filter((array) $this->previousAccessedColumns));
	}
コード例 #6
0
ファイル: WpLatte.php プロジェクト: ssuhss/Begara
 function render()
 {
     if ($this->getFile() == NULL) {
         throw new InvalidStateException("Template file name was not specified.");
     }
     $cache = new NCache($storage = $this->getCacheStorage(), 'wplatte');
     if ($storage instanceof NPhpFileStorage) {
         $storage->hint = str_replace(dirname(dirname($this->getFile())), '', $this->getFile());
     }
     $cached = $compiled = $cache->load($this->getFile());
     if ($compiled === NULL) {
         try {
             $compiled = "<?php\n\n// source file: {$this->getFile()}\n\n?>" . $this->compile();
         } catch (NTemplateException $e) {
             $e->setSourceFile($this->getFile());
             throw $e;
         }
         $cache->save($this->getFile(), $compiled, array(NCache::FILES => $this->getFile(), NCache::CONSTS => array('NFramework::REVISION', 'WPLATTE_CACHE_VERSION')));
         $cache->release();
         $cached = $cache->load($this->getFile());
     }
     if ($cached !== NULL && $storage instanceof NPhpFileStorage) {
         NLimitedScope::load($cached['file'], $this->getParams());
     } else {
         NLimitedScope::evaluate($compiled, $this->getParams());
     }
 }
コード例 #7
0
	/**
	 * Returns system DI container.
	 * @return SystemContainer
	 */
	public function createContainer()
	{
		if ($cacheDir = $this->getCacheDirectory()) {
			$cache = new NCache(new NPhpFileStorage($cacheDir), 'Nette.Configurator');
			$cacheKey = array($this->params, $this->files);
			$cached = $cache->load($cacheKey);
			if (!$cached) {
				$code = $this->buildContainer($dependencies);
				$cache->save($cacheKey, $code, array(
					NCache::FILES => $this->params['productionMode'] ? NULL : $dependencies,
				));
				$cached = $cache->load($cacheKey);
			}
			NLimitedScope::load($cached['file'], TRUE);

		} elseif ($this->files) {
			throw new InvalidStateException("Set path to temporary directory using setTempDirectory().");

		} else {
			NLimitedScope::evaluate($this->buildContainer()); // back compatibility with Environment
		}

		$container = new $this->params['container']['class'];
		$container->initialize();
		NEnvironment::setContext($container); // back compatibility
		return $container;
	}
コード例 #8
0
	/**
	 * Renders template to output.
	 * @return void
	 */
	public function render()
	{
		if ($this->file == NULL) { // intentionally ==
			throw new InvalidStateException("Template file name was not specified.");
		}

		$cache = new NCache($storage = $this->getCacheStorage(), 'Nette.FileTemplate');
		if ($storage instanceof NPhpFileStorage) {
			$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 (NTemplateException $e) {
				$e->setSourceFile($this->file);
				throw $e;
			}

			$cache->save($this->file, $compiled, array(
				NCache::FILES => $this->file,
				NCache::CONSTS => 'NFramework::REVISION',
			));
			$cached = $cache->load($this->file);
		}

		if ($cached !== NULL && $storage instanceof NPhpFileStorage) {
			NLimitedScope::load($cached['file'], $this->getParameters());
		} else {
			NLimitedScope::evaluate($compiled, $this->getParameters());
		}
	}