diff options
| author | thomasb <thomasb@208e9e7b-5314-0410-a742-e7e81cd9613c> | 2008-11-23 13:24:49 +0000 |
|---|---|---|
| committer | thomasb <thomasb@208e9e7b-5314-0410-a742-e7e81cd9613c> | 2008-11-23 13:24:49 +0000 |
| commit | d38bab3177f584dd9b4c6c39228e9301400deadd (patch) | |
| tree | ab0bf03207cac5aa002b75c4713fea2f0ccd9bbd | |
| parent | 6f94b0db16b02eebcc8e3582516d2c05bdc19d3b (diff) | |
Also clean cache table when removing old messages from cache
git-svn-id: https://svn.roundcube.net/trunk@2084 208e9e7b-5314-0410-a742-e7e81cd9613c
| -rw-r--r-- | roundcubemail/program/include/main.inc | 18 | ||||
| -rw-r--r-- | roundcubemail/program/include/session.inc | 8 |
2 files changed, 13 insertions, 13 deletions
diff --git a/roundcubemail/program/include/main.inc b/roundcubemail/program/include/main.inc index e531bd8d3..b5447c70a 100644 --- a/roundcubemail/program/include/main.inc +++ b/roundcubemail/program/include/main.inc @@ -151,19 +151,19 @@ function rcmail_temp_gc() * Garbage collector for cache entries. * Remove all expired message cache records */ -function rcmail_message_cache_gc() +function rcmail_cache_gc() { - global $DB, $CONFIG; - - // no cache lifetime configured - if (empty($CONFIG['message_cache_lifetime'])) - return; + $rcmail = rcmail::get_instance(); + $db = $rcmail->get_dbh(); // get target timestamp - $ts = get_offset_time($CONFIG['message_cache_lifetime'], -1); + $ts = get_offset_time($rcmail->config->get('message_cache_lifetime', '30d'), -1); - $DB->query("DELETE FROM ".get_table_name('messages')." - WHERE created < ".$DB->fromunixtime($ts)); + $db->query("DELETE FROM ".get_table_name('messages')." + WHERE created < " . $db->fromunixtime($ts)); + + $db->query("DELETE FROM ".get_table_name('cache')." + WHERE created < " . $db->fromunixtime($ts)); } diff --git a/roundcubemail/program/include/session.inc b/roundcubemail/program/include/session.inc index 3f01fcd53..f91a51a8c 100644 --- a/roundcubemail/program/include/session.inc +++ b/roundcubemail/program/include/session.inc @@ -125,12 +125,12 @@ function rcube_sess_gc($maxlifetime) return false; } - if ($rcmail->config->get('enable_caching')) - rcmail_message_cache_gc(); - // just delete all expired sessions $DB->query("DELETE FROM " . get_table_name('session') . " - WHERE changed < " . $now); + WHERE changed < " . $DB->fromunixtime(time() - $maxlifetime)); + + if ($rcmail->config->get('enable_caching')) + rcmail_cache_gc(); rcmail_temp_gc(); |
