save() public method

Saves the supplied value to the cache.
public save ( string $key, mixed $value ) : void
$key string
$value mixed
return void
Beispiel #1
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'));
 }
Beispiel #2
0
 public function save($hash, IQuery $query)
 {
     self::$secondLevelCache[$hash] = $query;
     $this->cacheAdapter->save($hash, $query);
 }
 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;
 }