Changeset 5898 in subversion
- Timestamp:
- Feb 21, 2012 4:43:39 PM (16 months ago)
- Location:
- trunk/roundcubemail/program/include
- Files:
-
- 6 edited
-
main.inc (modified) (1 diff)
-
rcmail.php (modified) (4 diffs)
-
rcube_imap.php (modified) (2 diffs)
-
rcube_imap_cache.php (modified) (1 diff)
-
rcube_session.php (modified) (1 diff)
-
rcube_storage.php (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
trunk/roundcubemail/program/include/main.inc
r5891 r5898 156 156 closedir($dir); 157 157 } 158 }159 160 161 /**162 * Garbage collector for cache entries.163 * Remove all expired message cache records164 * @return void165 */166 function rcmail_cache_gc()167 {168 $rcmail = rcmail::get_instance();169 $db = $rcmail->get_dbh();170 171 // get target timestamp172 $ts = get_offset_time($rcmail->config->get('message_cache_lifetime', '30d'), -1);173 174 $db->query("DELETE FROM ".get_table_name('cache_messages')175 ." WHERE changed < " . $db->fromunixtime($ts));176 177 $db->query("DELETE FROM ".get_table_name('cache_index')178 ." WHERE changed < " . $db->fromunixtime($ts));179 180 $db->query("DELETE FROM ".get_table_name('cache_thread')181 ." WHERE changed < " . $db->fromunixtime($ts));182 183 $db->query("DELETE FROM ".get_table_name('cache')184 ." WHERE created < " . $db->fromunixtime($ts));185 158 } 186 159 -
trunk/roundcubemail/program/include/rcmail.php
r5863 r5898 130 130 private $action_map = array(); 131 131 private $shutdown_functions = array(); 132 private $expunge_cache = false; 132 133 133 134 … … 768 769 769 770 $this->session->register_gc_handler('rcmail_temp_gc'); 770 if ($this->config->get('enable_caching')) 771 $this->session->register_gc_handler('rcmail_cache_gc'); 771 $this->session->register_gc_handler(array($this, 'cache_gc')); 772 772 773 773 // start PHP session (if not in CLI mode) … … 1279 1279 } 1280 1280 1281 if (is_object($this->storage)) 1281 if (is_object($this->storage)) { 1282 if ($this->expunge_cache) 1283 $this->storage->expunge_cache(); 1282 1284 $this->storage->close(); 1285 } 1283 1286 1284 1287 // before closing the database connection, write session data … … 1313 1316 { 1314 1317 $this->shutdown_functions[] = $function; 1318 } 1319 1320 1321 /** 1322 * Garbage collector for cache entries. 1323 * Set flag to expunge caches on shutdown 1324 */ 1325 function cache_gc() 1326 { 1327 // because this gc function is called before storage is initialized, 1328 // we just set a flag to expunge storage cache on shutdown. 1329 $this->expunge_cache = true; 1315 1330 } 1316 1331 -
trunk/roundcubemail/program/include/rcube_imap.php
r5812 r5898 3528 3528 if ($this->caching && !$this->cache) { 3529 3529 $rcmail = rcmail::get_instance(); 3530 $this->cache = $rcmail->get_cache('IMAP', $this->caching); 3530 $ttl = $rcmail->config->get('message_cache_lifetime', '10d') - mktime(); 3531 $this->cache = $rcmail->get_cache('IMAP', $this->caching, $ttl); 3531 3532 } 3532 3533 … … 3573 3574 $cache->remove($key, $prefix_mode); 3574 3575 } 3576 } 3577 3578 /** 3579 * Delete outdated cache entries 3580 */ 3581 public function expunge_cache() 3582 { 3583 if ($this->mcache) { 3584 $ttl = rcmail::get_instance()->config->get('message_cache_lifetime', '10d'); 3585 $this->mcache->expunge($ttl); 3586 } 3587 3588 if ($this->cache) 3589 $this->cache->expunge(); 3575 3590 } 3576 3591 -
trunk/roundcubemail/program/include/rcube_imap_cache.php
r5787 r5898 600 600 601 601 /** 602 * Delete cache entries older than TTL 603 * 604 * @param string $ttl Lifetime of message cache entries 605 */ 606 function expunge($ttl) 607 { 608 // get expiration timestamp 609 $ts = get_offset_time($ttl, -1); 610 611 $this->db->query("DELETE FROM ".get_table_name('cache_messages') 612 ." WHERE changed < " . $this->db->fromunixtime($ts)); 613 614 $this->db->query("DELETE FROM ".get_table_name('cache_index') 615 ." WHERE changed < " . $this->db->fromunixtime($ts)); 616 617 $this->db->query("DELETE FROM ".get_table_name('cache_thread') 618 ." WHERE changed < " . $this->db->fromunixtime($ts)); 619 } 620 621 622 /** 602 623 * Fetches index data from database 603 624 */ -
trunk/roundcubemail/program/include/rcube_session.php
r5787 r5898 333 333 * @param mixed Callback function 334 334 */ 335 public function register_gc_handler($func_name) 336 { 337 if ($func_name && !in_array($func_name, $this->gc_handlers)) 338 $this->gc_handlers[] = $func_name; 335 public function register_gc_handler($func) 336 { 337 foreach ($this->gc_handlers as $handler) { 338 if ($handler == $func) { 339 return; 340 } 341 } 342 343 $this->gc_handlers[] = $func; 339 344 } 340 345 -
trunk/roundcubemail/program/include/rcube_storage.php
r5787 r5898 972 972 abstract function get_cache($key); 973 973 974 /** 975 * Delete outdated cache entries 976 */ 977 abstract function expunge_cache(); 978 974 979 } // end class rcube_storage 975 980
Note: See TracChangeset
for help on using the changeset viewer.
