function DatabaseBackend::schemaDefinition

Same name in this branch
  1. 8.9.x core/lib/Drupal/Core/Flood/DatabaseBackend.php \Drupal\Core\Flood\DatabaseBackend::schemaDefinition()
Same name in other branches
  1. 9 core/lib/Drupal/Core/Flood/DatabaseBackend.php \Drupal\Core\Flood\DatabaseBackend::schemaDefinition()
  2. 9 core/lib/Drupal/Core/Cache/DatabaseBackend.php \Drupal\Core\Cache\DatabaseBackend::schemaDefinition()
  3. 10 core/lib/Drupal/Core/Flood/DatabaseBackend.php \Drupal\Core\Flood\DatabaseBackend::schemaDefinition()
  4. 10 core/lib/Drupal/Core/Cache/DatabaseBackend.php \Drupal\Core\Cache\DatabaseBackend::schemaDefinition()
  5. 11.x core/lib/Drupal/Core/Flood/DatabaseBackend.php \Drupal\Core\Flood\DatabaseBackend::schemaDefinition()
  6. 11.x core/lib/Drupal/Core/Cache/DatabaseBackend.php \Drupal\Core\Cache\DatabaseBackend::schemaDefinition()

Defines the schema for the {cache_*} bin tables.

@internal

1 call to DatabaseBackend::schemaDefinition()
DatabaseBackend::ensureBinExists in core/lib/Drupal/Core/Cache/DatabaseBackend.php
Check if the cache bin exists and create it if not.

File

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

Class

DatabaseBackend
Defines a default cache implementation.

Namespace

Drupal\Core\Cache

Code

public function schemaDefinition() {
    $schema = [
        'description' => 'Storage for the cache API.',
        'fields' => [
            'cid' => [
                'description' => 'Primary Key: Unique cache ID.',
                'type' => 'varchar_ascii',
                'length' => 255,
                'not null' => TRUE,
                'default' => '',
                'binary' => TRUE,
            ],
            'data' => [
                'description' => 'A collection of data to cache.',
                'type' => 'blob',
                'not null' => FALSE,
                'size' => 'big',
            ],
            'expire' => [
                'description' => 'A Unix timestamp indicating when the cache entry should expire, or ' . Cache::PERMANENT . ' for never.',
                'type' => 'int',
                'not null' => TRUE,
                'default' => 0,
            ],
            'created' => [
                'description' => 'A timestamp with millisecond precision indicating when the cache entry was created.',
                'type' => 'numeric',
                'precision' => 14,
                'scale' => 3,
                'not null' => TRUE,
                'default' => 0,
            ],
            'serialized' => [
                'description' => 'A flag to indicate whether content is serialized (1) or not (0).',
                'type' => 'int',
                'size' => 'small',
                'not null' => TRUE,
                'default' => 0,
            ],
            'tags' => [
                'description' => 'Space-separated list of cache tags for this entry.',
                'type' => 'text',
                'size' => 'big',
                'not null' => FALSE,
            ],
            'checksum' => [
                'description' => 'The tag invalidation checksum when this entry was saved.',
                'type' => 'varchar_ascii',
                'length' => 255,
                'not null' => TRUE,
            ],
        ],
        'indexes' => [
            'expire' => [
                'expire',
            ],
            'created' => [
                'created',
            ],
        ],
        'primary key' => [
            'cid',
        ],
    ];
    return $schema;
}

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