Changeset 913 in subversion


Ignore:
Timestamp:
Nov 8, 2007 4:50:47 AM (6 years ago)
Author:
thomasb
Message:

Optimize caching and avoid unnecessary IMAP requests

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/roundcubemail/program/include/rcube_imap.inc

    r912 r913  
    968968    if ($headers) 
    969969      { 
    970       if ($is_uid) 
    971         $this->uid_id_map[$mbox_name][$uid] = $headers->id; 
     970      if ($headers->uid && $headers->id) 
     971        $this->uid_id_map[$mailbox][$headers->uid] = $headers->id; 
    972972 
    973973      $this->add_message_cache($mailbox.'.msg', $headers->id, $headers); 
     
    10061006      { 
    10071007      $this->_msg_id = $msg_id; 
    1008       $headers = $this->get_headers($msg_id, NULL, FALSE); 
     1008      $headers = $this->get_headers($uid); 
    10091009       
    10101010      $struct = &$this->_structure_part($structure); 
     
    20672067  function &get_cached_message($key, $uid, $struct=false) 
    20682068    { 
    2069     if (!$this->caching_enabled) 
    2070       return FALSE; 
    2071  
    20722069    $internal_key = '__single_msg'; 
     2070     
    20732071    if ($this->caching_enabled && (!isset($this->cache[$internal_key][$uid]) || 
    20742072        ($struct && empty($this->cache[$internal_key][$uid]->structure)))) 
     
    21312129  function add_message_cache($key, $index, $headers, $struct=null) 
    21322130    { 
    2133     if (!$this->caching_enabled || empty($key) || !is_object($headers) || empty($headers->uid)) 
     2131    if (empty($key) || !is_object($headers) || empty($headers->uid)) 
     2132        return; 
     2133     
     2134    // add to internal (fast) cache 
     2135    $this->cache['__single_msg'][$headers->uid] = $headers; 
     2136    $this->cache['__single_msg'][$headers->uid]->structure = $struct; 
     2137     
     2138    // no further caching 
     2139    if (!$this->caching_enabled) 
    21342140      return; 
    2135        
     2141     
    21362142    // check for an existing record (probly headers are cached but structure not) 
    21372143    $sql_result = $this->db->query( 
     
    24892495      $mbox_name = $this->mailbox; 
    24902496       
    2491     return iil_C_ID2UID($this->conn, $mbox_name, $id); 
     2497    $index = array_flip($this->uid_id_map[$mbox_name]); 
     2498    if (isset($index[$id])) 
     2499      $uid = $index[$id]; 
     2500    else 
     2501      { 
     2502      $uid = iil_C_ID2UID($this->conn, $mbox_name, $id); 
     2503      $this->uid_id_map[$mbox_name][$uid] = $id; 
     2504      } 
     2505     
     2506    return $uid; 
    24922507    } 
    24932508 
Note: See TracChangeset for help on using the changeset viewer.