Author: Elliot Levin (elliotlevin@hotmail.com)
Exemplo n.º 1
0
 /**
  * @return ICacheAdapter
  */
 private static function getImplementation()
 {
     if (self::$cacheImplementation === null) {
         self::$cacheImplementation = new NullCache();
     }
     if (self::$isDevelopmentMode && !self::$hasBeenCleared) {
         self::$cacheImplementation->clear();
         self::$hasBeenCleared = true;
     }
     return self::$cacheImplementation;
 }
Exemplo n.º 2
0
 public function testThaGlobalNamespaceCacheWillNotClearOtherNamespaces()
 {
     $childNamespaceCache = $this->namespacedCache->forNamespace('CHILD::namespace');
     $childNamespaceCache->save('in-child-namespace-1', 1);
     $childNamespaceCache->save('in-child-namespace-2', 2);
     $this->namespacedCache->save('in-namespace', 2);
     $this->cache->inGlobalNamespace()->clear();
     $this->assertFalse($this->namespacedCache->contains('in-namespace'));
     $this->assertFalse($childNamespaceCache->contains('in-child-namespace-1'));
     $this->assertFalse($childNamespaceCache->contains('in-child-namespace-2'));
 }
Exemplo n.º 3
0
 public function remove($hash)
 {
     unset(self::$secondLevelCache[$hash]);
     $this->cacheAdapter->remove($hash);
 }
Exemplo n.º 4
0
 protected function loadCompiledQueryFromTemplate(Caching\ICacheAdapter $queryCache, $templateHash, IQueryTemplate $template, Queries\IResolvedParameterRegistry $parameters, callable $compileRequestCallback)
 {
     if ($template instanceof IStaticQueryTemplate) {
         return $template->getCompiledQuery();
     }
     $resolvedStructuralParameters = $template->resolveStructuralParameters($parameters, $hash);
     $compiledQueryHash = md5($templateHash . '-' . $hash);
     $compiledQuery = $queryCache->tryGet($compiledQueryHash);
     if (!$compiledQuery instanceof ICompiledQuery) {
         $compiledQuery = $compileRequestCallback($template, $resolvedStructuralParameters);
         $queryCache->save($compiledQueryHash, $compiledQuery);
     }
     return $compiledQuery;
 }