From 0890557ebb666dacf3356aae262ec79f486fa25d Mon Sep 17 00:00:00 2001 From: Michael Foster Date: Sun, 4 Aug 2013 04:48:13 -0400 Subject: Don't purge the ban list of expires bans every time somebody posts. Add a timer option. Less SQL queries when posting. --- inc/functions.php | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'inc/functions.php') diff --git a/inc/functions.php b/inc/functions.php index 8b2c4c7b..0c9b9983 100644 --- a/inc/functions.php +++ b/inc/functions.php @@ -687,9 +687,19 @@ function checkBan($board = 0) { // No reason to keep expired bans in the database (except those that haven't been viewed yet) function purge_bans() { + global $config; + + if ($config['cache']['enabled'] && $last_time_purged = cache::get('purged_bans_last')) { + if (time() - $last_time_purged < 60 * 30) + return; + } + $query = prepare("DELETE FROM ``bans`` WHERE `expires` IS NOT NULL AND `expires` < :time AND `seen` = 1"); $query->bindValue(':time', time()); $query->execute() or error(db_error($query)); + + if ($config['cache']['enabled']) + cache::set('purged_bans_last', time()); } function threadLocked($id) { -- cgit v1.3