function DatabaseStorageExpirable::schemaDefinition

Same name and namespace in other branches
  1. 10 core/lib/Drupal/Core/KeyValueStore/DatabaseStorageExpirable.php \Drupal\Core\KeyValueStore\DatabaseStorageExpirable::schemaDefinition()
  2. 11.x core/lib/Drupal/Core/KeyValueStore/DatabaseStorageExpirable.php \Drupal\Core\KeyValueStore\DatabaseStorageExpirable::schemaDefinition()

Defines the schema for the key_value_expire table.

Overrides DatabaseStorage::schemaDefinition

File

core/lib/Drupal/Core/KeyValueStore/DatabaseStorageExpirable.php, line 195

Class

DatabaseStorageExpirable
Defines a default key/value store implementation for expiring items.

Namespace

Drupal\Core\KeyValueStore

Code

public static function schemaDefinition() {
    return [
        'description' => 'Generic key/value storage table with an expiration.',
        'fields' => [
            'collection' => [
                'description' => 'A named collection of key and value pairs.',
                'type' => 'varchar_ascii',
                'length' => 128,
                'not null' => TRUE,
                'default' => '',
            ],
            'name' => [
                // KEY is an SQL reserved word, so use 'name' as the key's field name.
'description' => 'The key of the key/value pair.',
                'type' => 'varchar_ascii',
                'length' => 128,
                'not null' => TRUE,
                'default' => '',
            ],
            'value' => [
                'description' => 'The value of the key/value pair.',
                'type' => 'blob',
                'not null' => TRUE,
                'size' => 'big',
            ],
            'expire' => [
                'description' => 'The time since Unix epoch in seconds when this item expires. Defaults to the maximum possible time.',
                'type' => 'int',
                'not null' => TRUE,
                'default' => 2147483647,
            ],
        ],
        'primary key' => [
            'collection',
            'name',
        ],
        'indexes' => [
            'expire' => [
                'expire',
            ],
        ],
    ];
}

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