You are here

function apdqc_get_cache_tables in Asynchronous Prefetch Database Query Cache 7

Returns a list of all cache tables used.

Parameters

bool $get_truncated: Set to FALSE to not include "__truncated_table" tables in the return array.

bool $get_full_schema: Set to TRUE to get the schema with descriptions.

Return value

array Returns an array of cache tables.

6 calls to apdqc_get_cache_tables()
apdqc_admin_change_table_collation in ./apdqc.admin.inc
Convert cache tables collation to utf8_bin/ascii_bin.
apdqc_admin_change_table_engine in ./apdqc.admin.inc
Convert cache tables engine to InnoDB.
apdqc_admin_operations_form in ./apdqc.admin.inc
Form builder; perform apdqc operations.
apdqc_cron in ./apdqc.module
Implements hook_cron().
apdqc_get_cache_table_indexes in ./apdqc.admin.inc
Get all database indexes for the cache tables.

... See full list

File

./apdqc.admin.inc, line 1325
Admin page callbacks for the apdqc module.

Code

function apdqc_get_cache_tables($get_truncated = TRUE, $get_full_schema = FALSE) {
  $cache_tables =& drupal_static(__FUNCTION__, array());
  if (!isset($cache_tables[$get_truncated][$get_full_schema])) {
    if ($get_full_schema) {
      $schema = apdqc_get_full_schema();
    }
    else {
      $schema = drupal_get_schema();
    }
    foreach ($schema as $table_name => &$values) {
      if (strpos($table_name, 'cache') !== 0) {

        // Remove if not a cache* table.
        unset($schema[$table_name]);
        continue;
      }
      if (empty($schema[$table_name]['fields']['cid'])) {

        // Remove if no cid field.
        unset($schema[$table_name]);
        continue;
      }
    }
    if ($get_full_schema) {

      // Add in the cache*__truncated_table tables.
      if ($get_truncated) {
        foreach ($schema as $table_name => $values) {
          if (!array_key_exists($table_name . '__truncated_table', $schema) && db_table_exists($table_name . '__truncated_table')) {
            $schema[$table_name . '__truncated_table'] = $schema[$table_name];
          }
        }
      }
      else {
        foreach ($schema as $table_name => $values) {
          if (strpos(strrev($table_name), strrev('__truncated_table')) === 0) {
            unset($schema[$table_name]);
          }
        }
      }
      $cache_tables[$get_truncated][$get_full_schema] = $schema;
    }
    else {
      $schema = array_keys($schema);

      // Add in the cache*__truncated_table tables.
      if ($get_truncated) {
        foreach ($schema as $table_name) {
          if (!in_array($table_name . '__truncated_table', $schema) && db_table_exists($table_name . '__truncated_table')) {
            $schema[] = $table_name . '__truncated_table';
          }
        }
      }
      else {
        foreach ($schema as $key => $table_name) {
          if (strpos(strrev($table_name), strrev('__truncated_table')) === 0) {
            unset($schema[$key]);
          }
        }
      }
      $cache_tables[$get_truncated][$get_full_schema] = $schema;
    }
  }
  return $cache_tables[$get_truncated][$get_full_schema];
}