Commit ff190a27 by Scott

Handle caching on selectspecs

parent 0db22db7
......@@ -479,6 +479,18 @@
*/
function qa_db_single_select($selectspec)
{
// check for cached results
if (isset($selectspec['caching'])) {
$cacheHandler = Q2A_Storage_CacheManager::getInstance();
$cacheKey = 'query:' . $selectspec['caching']['key'];
if ($cacheHandler->isEnabled()) {
$queryData = $cacheHandler->get($cacheKey);
if ($queryData !== null)
return $queryData;
}
}
$query = 'SELECT ';
foreach ($selectspec['columns'] as $columnas => $columnfrom)
......@@ -491,6 +503,13 @@
qa_db_post_select($results, $selectspec); // post-processing
// save cached results
if (isset($selectspec['caching'])) {
if ($cacheHandler->isEnabled()) {
$cacheHandler->set($cacheKey, $results, $selectspec['caching']['ttl']);
}
}
return $results;
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment