You are here

protected function DatabaseCacheTagsChecksum::ensureTableExists in Drupal 9

Same name and namespace in other branches
  1. 8 core/lib/Drupal/Core/Cache/DatabaseCacheTagsChecksum.php \Drupal\Core\Cache\DatabaseCacheTagsChecksum::ensureTableExists()

Check if the cache tags table exists and create it if not.

2 calls to DatabaseCacheTagsChecksum::ensureTableExists()
DatabaseCacheTagsChecksum::doInvalidateTags in core/lib/Drupal/Core/Cache/DatabaseCacheTagsChecksum.php
Marks cache items with any of the specified tags as invalid.
DatabaseCacheTagsChecksum::getTagInvalidationCounts in core/lib/Drupal/Core/Cache/DatabaseCacheTagsChecksum.php
Fetches invalidation counts for cache tags.

File

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

Class

DatabaseCacheTagsChecksum
Cache tags invalidations checksum implementation that uses the database.

Namespace

Drupal\Core\Cache

Code

protected function ensureTableExists() {
  try {
    $database_schema = $this->connection
      ->schema();

    // Create the cache tags table if it does not exist.
    if (!$database_schema
      ->tableExists('cachetags')) {
      $schema_definition = $this
        ->schemaDefinition();
      $database_schema
        ->createTable('cachetags', $schema_definition);
      return TRUE;
    }
  } catch (DatabaseException $e) {
    return TRUE;
  }
  return FALSE;
}