function apdqc_admin_convert_table_to_memory in Asynchronous Prefetch Database Query Cache 7
Convert semaphore table to MEMORY.
Parameters
bool $show_msg: Set to FALSE to not run drupal_set_message().
1 call to apdqc_admin_convert_table_to_memory()
- drush_apdqc in ./
apdqc.drush.inc - Drush command to all all the apdqc functions.
1 string reference to 'apdqc_admin_convert_table_to_memory'
- apdqc_admin_operations_form in ./
apdqc.admin.inc - Form builder; perform apdqc operations.
File
- ./
apdqc.admin.inc, line 474 - Admin page callbacks for the apdqc module.
Code
function apdqc_admin_convert_table_to_memory($show_msg = TRUE) {
$before = apdqc_semaphore_conversion();
// Get current table indexes.
$indexes = db_query('SHOW INDEX FROM {semaphore}')
->fetchAllAssoc('Key_name');
// Run the commands.
db_query('ALTER TABLE {semaphore} ENGINE = MEMORY');
db_query('ALTER TABLE {semaphore} DROP PRIMARY KEY');
db_query('ALTER TABLE {semaphore} ADD PRIMARY KEY (name, value) USING BTREE');
if (!empty($indexes['name'])) {
db_query('ALTER TABLE {semaphore} DROP INDEX name');
}
db_query('ALTER TABLE {semaphore} ADD UNIQUE name (name) USING BTREE');
db_query('ALTER TABLE {semaphore} DROP INDEX value');
db_query('ALTER TABLE {semaphore} ADD INDEX value (value) USING BTREE');
db_query('ALTER TABLE {semaphore} DROP INDEX expire');
db_query('ALTER TABLE {semaphore} ADD INDEX expire (expire) USING BTREE');
// Let user know it worked.
if ($show_msg !== FALSE) {
$conversion = apdqc_semaphore_conversion();
if ($before != 1) {
drupal_set_message(t('APDQC: semaphore table is already using the MEMORY engine.'));
}
elseif ($conversion == 1) {
drupal_set_message(t('APDQC: semaphore table was not converted to MEMORY engine. You need to do this manually by using a tool like phpmyadmin.'), 'error');
}
else {
drupal_set_message(t('APDQC: semaphore table converted to MEMORY engine'));
}
}
variable_set('apdqc_semaphore_memory', TRUE);
}