protected function DatabaseBackend::ensureBinExists

protected DatabaseBackend::ensureBinExists()

Check if the cache bin exists and create it if not.

File

core/lib/Drupal/Core/Cache/DatabaseBackend.php, line 356

Class

DatabaseBackend
Defines a default cache implementation.

Namespace

Drupal\Core\Cache

Code

protected function ensureBinExists() {
  try {
    $database_schema = $this->connection->schema();
    if (!$database_schema->tableExists($this->bin)) {
      $schema_definition = $this->schemaDefinition();
      $database_schema->createTable($this->bin, $schema_definition);
      return TRUE;
    }
  }
  // If another process has already created the cache table, attempting to
  // recreate it will throw an exception. In this case just catch the
  // exception and do nothing.
  catch (SchemaObjectExistsException $e) {
    return TRUE;
  }
  return FALSE;
}

© 2001–2016 by the original authors
Licensed under the GNU General Public License, version 2 and later.
Drupal is a registered trademark of Dries Buytaert.
https://api.drupal.org/api/drupal/core!lib!Drupal!Core!Cache!DatabaseBackend.php/function/DatabaseBackend::ensureBinExists/8.1.x