You are here

service_container.install in Service Container 7

Same filename and directory in other branches
  1. 7.2 service_container.install

Creates the following tables:

  • key_value
  • key_value_expire

File

service_container.install
View source
<?php

/**
 * @file
 * Creates the following tables:
 *
 * - key_value
 * - key_value_expire
 */

/**
 * Implements hook_schema().
 */
function service_container_schema() {
  $schema = array();
  $schema['key_value'] = array(
    'description' => 'Generic key-value storage table. See the state system for an example.',
    'fields' => array(
      'collection' => array(
        'description' => 'A named collection of key and value pairs.',
        'type' => 'varchar',
        'length' => 128,
        'not null' => TRUE,
        'default' => '',
      ),
      'name' => array(
        'description' => 'The key of the key-value pair. As KEY is a SQL reserved keyword, name was chosen instead.',
        'type' => 'varchar',
        'length' => 128,
        'not null' => TRUE,
        'default' => '',
      ),
      'value' => array(
        'description' => 'The value.',
        'type' => 'blob',
        'not null' => TRUE,
        'size' => 'big',
      ),
    ),
    'primary key' => array(
      'collection',
      'name',
    ),
  );
  $schema['key_value_expire'] = array(
    'description' => 'Generic key/value storage table with an expiration.',
    'fields' => array(
      'collection' => array(
        'description' => 'A named collection of key and value pairs.',
        'type' => 'varchar',
        'length' => 128,
        'not null' => TRUE,
        'default' => '',
      ),
      'name' => array(
        // 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',
        'length' => 128,
        'not null' => TRUE,
        'default' => '',
      ),
      'value' => array(
        'description' => 'The value of the key/value pair.',
        'type' => 'blob',
        'not null' => TRUE,
        'size' => 'big',
      ),
      'expire' => array(
        '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' => array(
      'collection',
      'name',
    ),
    'indexes' => array(
      'all' => array(
        'name',
        'collection',
        'expire',
      ),
      'expire' => array(
        'expire',
      ),
    ),
  );
  return $schema;
}

Functions

Namesort descending Description
service_container_schema Implements hook_schema().