function apdqc_reap_async_query in Asynchronous Prefetch Database Query Cache 7
Create a new MySQLi connection.
Parameters
array $db_info: Static var from 'apdqc_get_db_object'.
mysqli $mysqli: mysqlnd connection object. Passed by reference.
array $new_cids: An array of cache IDs.
array $new_tables: An array of table names.
1 call to apdqc_reap_async_query()
- apdqc_get_db_object in ./
apdqc.mysql.inc - Return a mysqli object that is ready to be used.
File
- ./
apdqc.mysql.inc, line 486 - APDQC Database interface code for MySQL database servers.
Code
function apdqc_reap_async_query(array $db_info, mysqli &$mysqli, array $new_cids = array(), array $new_tables = array()) {
// Get database query logger.
if (variable_get('devel_query_display', 0) && variable_get('apdqc_verbose_devel_output', APDQC_VERBOSE_DEVEL_OUTPUT)) {
$logger = Database::getConnection()
->getLogger();
// Start timer if DB logger is enabled.
if (!empty($logger)) {
$query_start = microtime(TRUE);
}
}
// Wait for the query to finish.
$old_tables = $db_info['pool'][$mysqli->thread_id][1];
$old_cids = $db_info['pool'][$mysqli->thread_id][2];
$query_result = @$mysqli
->reap_async_query();
if (!empty($query_result)) {
apdqc_async_data($query_result, $old_tables, $old_cids);
}
// Stop timer & write to the log if DB logger is enabled.
if (!empty($logger) && is_object($logger)) {
$logit = FALSE;
$query_end = microtime(TRUE);
$data = 'Waiting for ASYNC READ to finish. ';
if (isset($old_cids['*'])) {
$old_cids = $old_cids['*'];
}
$intersect = array_intersect($old_tables, $new_tables);
$extra_data = '';
if (!empty($intersect)) {
$extra_data .= ' TABLE INTERSECTION on the ' . implode(', ', $intersect) . ' table(s).';
$extra_data .= ' OLD TABLES ' . implode(', ', $old_tables) . '.';
$logit = TRUE;
}
$intersect = array_intersect($old_cids, $new_cids);
if (!empty($intersect)) {
$extra_data .= ' CID INTERSECTION on these cids: ' . implode(', ', $intersect) . '.';
$extra_data .= ' OLD CID ' . implode(', ', $old_cids) . '.';
$logit = TRUE;
}
$extra_data .= ' Next query lists what closed this query out; a prefetch hit is good.';
$data .= $extra_data;
$data = trim($data);
$extra_data = 'thread_id:' . $mysqli->thread_id . ' ';
if ($logit) {
require_once 'apdqc.log.inc';
$statement = new ApdqcFakeDatabaseStatement($data, $extra_data);
$logger
->log($statement, array(), $query_end - $query_start);
}
}
}