From f7cefa1c87439c7c2ef9c3599be44f5be25d6d8d Mon Sep 17 00:00:00 2001 From: Exile Date: Tue, 26 Aug 2014 13:40:41 +0400 Subject: [PATCH] Some cache MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit кешируем юзердату для трекера, правим кеширование системы жалоб, увеличиваем кеш для списка тех кто онлайн до минуты. --- upload/includes/functions.php | 18 +++++++++++++----- upload/includes/functions_report.php | 11 +++-------- upload/includes/online_userlist.php | 4 ++-- 3 files changed, 18 insertions(+), 15 deletions(-) diff --git a/upload/includes/functions.php b/upload/includes/functions.php index 9e45a33b5..980bfba53 100644 --- a/upload/includes/functions.php +++ b/upload/includes/functions.php @@ -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) diff --git a/upload/includes/functions_report.php b/upload/includes/functions_report.php index 40f7ab60f..448bb3ce3 100644 --- a/upload/includes/functions_report.php +++ b/upload/includes/functions_report.php @@ -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'); } // diff --git a/upload/includes/online_userlist.php b/upload/includes/online_userlist.php index 43896b20c..eaa5a18d6 100644 --- a/upload/includes/online_userlist.php +++ b/upload/includes/online_userlist.php @@ -149,5 +149,5 @@ $online['cnt'] = $online_short['cnt'] = <<set('online_'.$userdata['user_lang'], $online, 45); -CACHE('bb_cache')->set('online_short_'.$userdata['user_lang'], $online_short, 45); \ No newline at end of file +CACHE('bb_cache')->set('online_'.$userdata['user_lang'], $online, 60); +CACHE('bb_cache')->set('online_short_'.$userdata['user_lang'], $online_short, 60); \ No newline at end of file