You are here

public function RenderCache::clear in RESTful 7.2

Clears the cache for the given cache object.

Overrides RenderCacheInterface::clear

File

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

Class

RenderCache
Class RenderCache.

Namespace

Drupal\restful\RenderCache

Code

public function clear() {

  // Remove the cache.
  $this->cacheObject
    ->clear($this
    ->generateCacheId());

  // Delete all cache fragments for that hash.
  $query = new \EntityFieldQuery();
  $results = $query
    ->entityCondition('entity_type', 'cache_fragment')
    ->propertyCondition('hash', $this
    ->generateCacheId())
    ->execute();
  if (empty($results['cache_fragment'])) {
    return;
  }

  // Delete the actual entities.
  entity_delete_multiple('cache_fragment', array_keys($results['cache_fragment']));
}