Commit 391068b6 by Scott

Option to prevent caching new questions

parent fbb97ca1
...@@ -732,7 +732,7 @@ ...@@ -732,7 +732,7 @@
* Generate array of split HTML (prefix, data, suffix) to represent a timestamp, optionally with the full date. * Generate array of split HTML (prefix, data, suffix) to represent a timestamp, optionally with the full date.
* *
* @param int $timestamp Unix timestamp. * @param int $timestamp Unix timestamp.
* @param bool $fulldatedays Number of days after which to show the full date. * @param int $fulldatedays Number of days after which to show the full date.
* @return array The HTML. * @return array The HTML.
*/ */
function qa_when_to_html($timestamp, $fulldatedays) function qa_when_to_html($timestamp, $fulldatedays)
......
...@@ -215,7 +215,8 @@ ...@@ -215,7 +215,8 @@
'avatar_users_size' => 30, 'avatar_users_size' => 30,
'caching_catwidget_time' => 30, 'caching_catwidget_time' => 30,
'caching_enabled' => 0, 'caching_enabled' => 0,
'caching_q_time' => 5, 'caching_q_start' => 7,
'caching_q_time' => 30,
'caching_qlist_time' => 5, 'caching_qlist_time' => 5,
'captcha_on_anon_post' => 1, 'captcha_on_anon_post' => 1,
'captcha_on_feedback' => 1, 'captcha_on_feedback' => 1,
......
...@@ -47,6 +47,7 @@ ...@@ -47,6 +47,7 @@
'block_ips_write' => 'Blocked IP addresses - separate by spaces or commas:', 'block_ips_write' => 'Blocked IP addresses - separate by spaces or commas:',
'caching_catwidget_time' => 'Cache category widget for:', 'caching_catwidget_time' => 'Cache category widget for:',
'caching_enabled' => 'Enable caching:', 'caching_enabled' => 'Enable caching:',
'caching_q_start' => 'Start caching questions after:',
'caching_q_time' => 'Cache question pages for:', 'caching_q_time' => 'Cache question pages for:',
'caching_qlist_time' => 'Cache question lists for:', 'caching_qlist_time' => 'Cache question lists for:',
'captcha_module' => 'Use captcha module:', 'captcha_module' => 'Use captcha module:',
......
...@@ -74,6 +74,7 @@ ...@@ -74,6 +74,7 @@
'avatar_store_size' => 'number', 'avatar_store_size' => 'number',
'avatar_users_size' => 'number', 'avatar_users_size' => 'number',
'caching_catwidget_time' => 'number', 'caching_catwidget_time' => 'number',
'caching_q_start' => 'number',
'caching_q_time' => 'number', 'caching_q_time' => 'number',
'caching_qlist_time' => 'number', 'caching_qlist_time' => 'number',
'columns_tags' => 'number', 'columns_tags' => 'number',
...@@ -646,13 +647,7 @@ ...@@ -646,13 +647,7 @@
$subtitle = 'admin/caching_title'; $subtitle = 'admin/caching_title';
$formstyle = 'wide'; $formstyle = 'wide';
$showoptions = array('caching_enabled', 'caching_q_time', 'caching_qlist_time', 'caching_catwidget_time'); $showoptions = array('caching_enabled', 'caching_q_start', 'caching_q_time', 'caching_qlist_time', 'caching_catwidget_time');
$checkboxtodisplay = array(
'caching_q_time' => 'option_caching_enabled',
'caching_qlist_time' => 'option_caching_enabled',
'caching_catwidget_time' => 'option_caching_enabled',
);
break; break;
...@@ -1555,7 +1550,10 @@ ...@@ -1555,7 +1550,10 @@
case 'caching_qlist_time': case 'caching_qlist_time':
case 'caching_catwidget_time': case 'caching_catwidget_time':
$optionfield['note'] = qa_lang_html_sub('main/x_minutes', ''); $optionfield['note'] = qa_lang_html_sub('main/x_minutes', '');
break; break;
case 'caching_q_start':
$optionfield['note'] = qa_lang_html_sub('main/x_days', '');
break;
} }
if (isset($feedrequest) && $value) if (isset($feedrequest) && $value)
...@@ -1786,7 +1784,6 @@ ...@@ -1786,7 +1784,6 @@
case 'caching': case 'caching':
$cacheManager = Q2A_Storage_CacheManager::getInstance(); $cacheManager = Q2A_Storage_CacheManager::getInstance();
$qa_content['error'] = $cacheManager->getError(); $qa_content['error'] = $cacheManager->getError();
break; break;
} }
......
...@@ -153,10 +153,13 @@ ...@@ -153,10 +153,13 @@
} }
// Save question data to cache // Save question data to cache (if older than configured limit)
if ($saveCache) { if ($saveCache) {
$cacheHandler->set($cacheKey, $questionData, qa_opt('caching_q_time')); $questionAge = qa_opt('db_time') - $question['created'];
if ($questionAge > 86400 * qa_opt('caching_q_start')) {
$cacheHandler->set($cacheKey, $questionData, qa_opt('caching_q_time'));
}
} }
......
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