Some cache

кешируем юзердату для трекера, правим кеширование системы жалоб, увеличиваем кеш для списка тех кто онлайн до минуты.
This commit is contained in:
Exile 2014-08-26 13:40:41 +04:00
commit f7cefa1c87
3 changed files with 18 additions and 15 deletions

View file

@ -1210,11 +1210,19 @@ function wbr ($text, $max_word_length = HTML_WBR_LENGTH)
function get_bt_userdata ($user_id)
{
return DB()->fetch_row("SELECT bt.*, SUM(tr.speed_up) as speed_up, SUM(tr.speed_down) as speed_down
FROM ". BB_BT_USERS ." bt
LEFT JOIN ". BB_BT_TRACKER ." tr ON (bt.user_id = tr.user_id)
WHERE bt.user_id = ". (int) $user_id ."
GROUP BY bt.user_id");
if (!$btu = CACHE('bb_cache')->get('btu_' . $user_id))
{
$btu = DB()->fetch_row("
SELECT bt.*, SUM(tr.speed_up) AS speed_up, SUM(tr.speed_down) AS speed_down
FROM ". BB_BT_USERS ." bt
LEFT JOIN ". BB_BT_TRACKER ." tr ON (bt.user_id = tr.user_id)
WHERE bt.user_id = ". (int) $user_id ."
GROUP BY bt.user_id
LIMIT 1
");
CACHE('bb_cache')->set('btu_' . $user_id, $btu, 300);
}
return $btu;
}
function get_bt_ratio ($btu)

View file

@ -78,7 +78,7 @@ function report_modules_obtain()
$modules = DB()->sql_fetchrowset($result);
DB()->sql_freeresult($result);
CACHE('bb_cache')->set('report_modules_obtain', $modules, 300);
CACHE('bb_cache')->set('report_modules_obtain', $modules, 600);
}
if (empty($modules)) {
@ -527,17 +527,15 @@ function report_count_obtain()
}
if ($userdata['user_level'] == ADMIN) {
if (!CACHE('bb_cache')->get('report_count_obtain_exp') || (CACHE('bb_cache')->get('report_count_obtain_exp') + 300) < TIMENOW) {
if (!$report_count = CACHE('bb_cache')->get('report_count_obtain')) {
$sql = 'SELECT COUNT(report_id) AS report_count FROM ' . BB_REPORTS . ' WHERE report_status IN(' . REPORT_NEW . ', ' . REPORT_OPEN . ')';
if (!$result = DB()->sql_query($sql)) {
bb_die('Could not obtain report count #1');
}
$report_count = DB()->sql_fetchfield('report_count', 0, $result);
DB()->sql_freeresult($result);
CACHE('bb_cache')->set('report_count_obtain', $report_count, 300);
CACHE('bb_cache')->set('report_count_obtain_exp', (TIMENOW + 300), 300);
CACHE('bb_cache')->set('report_count_obtain', $report_count, 600);
}
$report_count = CACHE('bb_cache')->get('report_count_obtain');
} else if ($userdata['user_level'] != MOD) {
$report_count = 0;
} else if (!$bb_cfg['report_subject_auth']) {
@ -917,7 +915,6 @@ function report_insert($module_id, $report_subject, $report_reason, $report_titl
}
CACHE('bb_cache')->rm('report_count_obtain');
CACHE('bb_cache')->rm('report_count_obtain_exp');
return $report_id;
}
@ -995,7 +992,6 @@ function reports_update_status($report_ids, $report_status, $comment = '', $auth
}
CACHE('bb_cache')->rm('report_count_obtain');
CACHE('bb_cache')->rm('report_count_obtain_exp');
}
//
@ -1069,7 +1065,6 @@ function reports_delete($report_ids, $auth_check = true, $module_action = true)
}
CACHE('bb_cache')->rm('report_count_obtain');
CACHE('bb_cache')->rm('report_count_obtain_exp');
}
//

View file

@ -149,5 +149,5 @@ $online['cnt'] = $online_short['cnt'] = <<<HTML
]
HTML;
CACHE('bb_cache')->set('online_'.$userdata['user_lang'], $online, 45);
CACHE('bb_cache')->set('online_short_'.$userdata['user_lang'], $online_short, 45);
CACHE('bb_cache')->set('online_'.$userdata['user_lang'], $online, 60);
CACHE('bb_cache')->set('online_short_'.$userdata['user_lang'], $online_short, 60);