function DatabaseBackend::ensureBinExists

Same name in other branches
  1. 8.9.x core/lib/Drupal/Core/Cache/DatabaseBackend.php \Drupal\Core\Cache\DatabaseBackend::ensureBinExists()
  2. 10 core/lib/Drupal/Core/Cache/DatabaseBackend.php \Drupal\Core\Cache\DatabaseBackend::ensureBinExists()
  3. 11.x core/lib/Drupal/Core/Cache/DatabaseBackend.php \Drupal\Core\Cache\DatabaseBackend::ensureBinExists()

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

3 calls to DatabaseBackend::ensureBinExists()
DatabaseBackend::deleteAll in core/lib/Drupal/Core/Cache/DatabaseBackend.php
Deletes all cache items in a bin.
DatabaseBackend::deleteMultiple in core/lib/Drupal/Core/Cache/DatabaseBackend.php
Deletes multiple items from the cache.
DatabaseBackend::setMultiple in core/lib/Drupal/Core/Cache/DatabaseBackend.php
Store multiple items in the persistent cache.

File

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

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;
        }
    } catch (DatabaseException $e) {
        return TRUE;
    }
    return FALSE;
}

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