You are here

public function RenderCache::get in RESTful 7.2

Get the cache.

Return value

mixed The cache value.

Overrides RenderCacheInterface::get

File

src/RenderCache/RenderCache.php, line 76
Contains \Drupal\restful\RenderCache\RenderCache.

Class

RenderCache
Class RenderCache.

Namespace

Drupal\restful\RenderCache

Code

public function get() {
  $cid = $this
    ->generateCacheId();
  $query = new \EntityFieldQuery();
  $count = $query
    ->entityCondition('entity_type', 'cache_fragment')
    ->propertyCondition('hash', $cid)
    ->count()
    ->execute();
  if ($count) {
    return $this->cacheObject
      ->get($cid);
  }

  // If there are no cache fragments for the given hash then clear the cache
  // and return NULL.
  $this->cacheObject
    ->clear($cid);
  return NULL;
}