tryGet() public method

Attempt to get the cached value associated with the supplied key
public tryGet ( string $key ) : mixed
$key string
return mixed
Exemplo n.º 1
0
 public function tryGet($hash)
 {
     if (!isset(self::$secondLevelCache[$hash])) {
         self::$secondLevelCache[$hash] = $this->cacheAdapter->tryGet($hash) ?: null;
     }
     $cachedValue = self::$secondLevelCache[$hash];
     return $cachedValue instanceof IQuery ? $cachedValue : null;
 }
Exemplo n.º 2
0
 public function testThatCacheDoesNotGetValuesOutsideOfNamespace()
 {
     $this->cache->save('not-in-namespace', true);
     $this->assertSame($this->cache->tryGet('not-in-namespace'), true);
     $this->assertSame($this->namespacedCache->tryGet('not-in-namespace'), null);
 }
Exemplo n.º 3
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;
 }