Also clean cache table when removing old messages from cache

release-0.6
thomascube 16 years ago
parent 69ad1e8124
commit 29c64b0bdd

@ -151,19 +151,19 @@ function rcmail_temp_gc()
* Garbage collector for cache entries. * Garbage collector for cache entries.
* Remove all expired message cache records * Remove all expired message cache records
*/ */
function rcmail_message_cache_gc() function rcmail_cache_gc()
{ {
global $DB, $CONFIG; $rcmail = rcmail::get_instance();
$db = $rcmail->get_dbh();
// no cache lifetime configured
if (empty($CONFIG['message_cache_lifetime']))
return;
// get target timestamp // 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')." $db->query("DELETE FROM ".get_table_name('messages')."
WHERE created < ".$DB->fromunixtime($ts)); WHERE created < " . $db->fromunixtime($ts));
$db->query("DELETE FROM ".get_table_name('cache')."
WHERE created < " . $db->fromunixtime($ts));
} }

@ -125,12 +125,12 @@ function rcube_sess_gc($maxlifetime)
return false; return false;
} }
if ($rcmail->config->get('enable_caching'))
rcmail_message_cache_gc();
// just delete all expired sessions // just delete all expired sessions
$DB->query("DELETE FROM " . get_table_name('session') . " $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(); rcmail_temp_gc();

Loading…
Cancel
Save