function DatabaseCacheTagsChecksum::doInvalidateTags

Same name in other branches
  1. 9 core/lib/Drupal/Core/Cache/DatabaseCacheTagsChecksum.php \Drupal\Core\Cache\DatabaseCacheTagsChecksum::doInvalidateTags()
  2. 8.9.x core/lib/Drupal/Core/Cache/DatabaseCacheTagsChecksum.php \Drupal\Core\Cache\DatabaseCacheTagsChecksum::doInvalidateTags()
  3. 10 core/lib/Drupal/Core/Cache/DatabaseCacheTagsChecksum.php \Drupal\Core\Cache\DatabaseCacheTagsChecksum::doInvalidateTags()

Overrides CacheTagsChecksumTrait::doInvalidateTags

File

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

Class

DatabaseCacheTagsChecksum
Cache tags invalidations checksum implementation that uses the database.

Namespace

Drupal\Core\Cache

Code

protected function doInvalidateTags(array $tags) {
    try {
        foreach ($tags as $tag) {
            $this->connection
                ->merge('cachetags')
                ->insertFields([
                '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()) {
            throw $e;
        }
    }
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.