DatabaseCacheTagsChecksum::invalidateTags

public DatabaseCacheTagsChecksum::invalidateTags(array $tags)

Marks cache items with any of the specified tags as invalid.

Parameters

string[] $tags: The list of tags for which to invalidate cache items.

Overrides CacheTagsInvalidatorInterface::invalidateTags

File

core/lib/Drupal/Core/Cache/DatabaseCacheTagsChecksum.php, line 49

Class

DatabaseCacheTagsChecksum
Cache tags invalidations checksum implementation that uses the database.

Namespace

Drupal\Core\Cache

Code

public function invalidateTags(array $tags) {
  try {
    foreach ($tags as $tag) {
      // Only invalidate tags once per request unless they are written again.
      if (isset($this->invalidatedTags[$tag])) {
        continue;
      }
      $this->invalidatedTags[$tag] = TRUE;
      unset($this->tagCache[$tag]);
      $this->connection->merge('cachetags')
        ->insertFields(array('invalidations' => 1))
        ->expression('invalidations', 'invalidations + 1')
        ->key('tag', $tag)
        ->execute();
    }
  }
  catch (\Exception $e) {
    // Create the cache table, which will be empty. This fixes cases during
    // core install where cache tags are invalidated before the table is
    // created.
    if (!$this->ensureTableExists()) {
      $this->catchException($e);
    }
  }
}
doc_Drupal
2016-10-29 08:59:43
Comments
Leave a Comment

Please login to continue.