Changeset cc95700 in github


Ignore:
Timestamp:
Feb 5, 2006 10:38:51 AM (7 years ago)
Author:
thomascube <thomas@…>
Branches:
master, HEAD, courier-fix, dev-browser-capabilities, pdo, release-0.6, release-0.7, release-0.8
Children:
bde645f
Parents:
fd80c1e
Message:

Added message cache garbage collector

Files:
4 edited

Legend:

Unmodified
Added
Removed
  • config/main.inc.php.dist

    r58e3602a rcc95700  
    2222// this is recommended if the IMAP server does not run on the same machine 
    2323$rcmail_config['enable_caching'] = TRUE; 
     24 
     25// lifetime of message cache 
     26// possible units: s, m, h, d, w 
     27$rcmail_config['message_cache_lifetime'] = '10d'; 
    2428 
    2529// automatically create a new RoundCube user when log-in the first time. 
  • program/include/main.inc

    r58e3602a rcc95700  
    698698 
    699699 
     700// remove all expired message cache records 
     701function rcmail_message_cache_gc() 
     702  { 
     703  global $DB, $CONFIG; 
     704   
     705  // no cache lifetime configured 
     706  if (empty($CONFIG['message_cache_lifetime'])) 
     707    return; 
     708   
     709  // get target timestamp 
     710  $ts = get_offset_time($CONFIG['message_cache_lifetime'], -1); 
     711   
     712  $DB->query("DELETE FROM ".get_table_name('messages')." 
     713             WHERE  created < ".$DB->fromunixtime($ts)); 
     714  } 
     715 
    700716 
    701717// convert a string from one charset to another 
     
    710726     
    711727  // convert charset using iconv module   
    712   if (0 && function_exists('iconv') && $from!='UTF-7' && $to!='UTF-7') { 
     728  if (function_exists('iconv') && $from!='UTF-7' && $to!='UTF-7') { 
    713729    return iconv($from, $to, $str); 
    714730    } 
     
    15071523 
    15081524 
     1525/****** debugging function ********/ 
     1526 
    15091527function rcube_timer() 
    15101528  { 
  • program/include/rcube_shared.inc

    r3f9edb4 rcc95700  
    13541354 
    13551355 
     1356// create a unix timestamp with a specified offset from now 
     1357function get_offset_time($offset_str, $factor=1) 
     1358  { 
     1359  if (preg_match('/^([0-9]+)\s*([smhdw])/i', $offset_str, $regs)) 
     1360    { 
     1361    $amount = (int)$regs[1]; 
     1362    $unit = strtolower($regs[2]); 
     1363    } 
     1364  else 
     1365    { 
     1366    $amount = (int)$offset_str; 
     1367    $unit = 's'; 
     1368    } 
     1369     
     1370  $ts = mktime(); 
     1371  switch ($unit) 
     1372    { 
     1373    case 'w': 
     1374      $amount *= 7; 
     1375    case 'd': 
     1376      $amount *= 24; 
     1377    case 'h': 
     1378      $amount *= 60; 
     1379    case 'h': 
     1380      $amount *= 60; 
     1381    case 's': 
     1382      $ts += $amount * $factor; 
     1383    } 
     1384 
     1385  return $ts; 
     1386  } 
     1387 
     1388 
    13561389?> 
  • program/include/session.inc

    r1cded85 rcc95700  
    107107 
    108108  rcmail_clear_session_temp($key); 
    109  
    110109  return TRUE; 
    111110  } 
     
    143142    rcmail_clear_session_temp($key); 
    144143 
     144  // also run message cache GC 
     145  rcmail_message_cache_gc(); 
     146 
    145147  return TRUE; 
    146148  } 
Note: See TracChangeset for help on using the changeset viewer.