Changeset 38bf4253 in github


Ignore:
Timestamp:
Sep 24, 2009 8:08:23 AM (4 years ago)
Author:
alecpl <alec@…>
Branches:
master, HEAD, courier-fix, dev-browser-capabilities, pdo, release-0.6, release-0.7, release-0.8
Children:
c2e697f
Parents:
9e2a7af
Message:
  • Fix cache status checking + improve cache operations performance (#1486104)
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • CHANGELOG

    r93a88c9 r38bf4253  
    22=========================== 
    33 
     4- Fix cache status checking + improve cache operations performance (#1486104) 
    45- Prevent from setting INBOX as any of special folders (#1486114) 
    56- Fix regular expression for e-mail address (#1486152) 
  • program/include/rcube_imap.php

    r1cead0c r38bf4253  
    486486  private function _messagecount($mailbox='', $mode='ALL', $force=FALSE) 
    487487    { 
    488     $a_mailbox_cache = FALSE; 
    489488    $mode = strtoupper($mode); 
    490489 
     
    21412140  function get_cache($key) 
    21422141    { 
    2143     // read cache 
    2144     if (!isset($this->cache[$key]) && $this->caching_enabled) 
     2142    // read cache (if it was not read before) 
     2143    if (!count($this->cache) && $this->caching_enabled) 
    21452144      { 
    21462145      return $this->_read_cache_record($key); 
     
    22192218        $sql_key = preg_replace('/^IMAP\./', '', $sql_arr['cache_key']); 
    22202219        $this->cache_keys[$sql_key] = $sql_arr['cache_id']; 
    2221         $this->cache[$sql_key] = $sql_arr['data'] ? unserialize($sql_arr['data']) : FALSE; 
     2220        if (!isset($this->cache[$sql_key])) 
     2221          $this->cache[$sql_key] = $sql_arr['data'] ? unserialize($sql_arr['data']) : FALSE; 
    22222222        } 
    22232223      } 
     
    22342234      return FALSE; 
    22352235 
    2236     // check if we already have a cache entry for this key 
    2237     if (!isset($this->cache_keys[$key])) 
    2238       { 
     2236    // update existing cache record 
     2237    if ($this->cache_keys[$key]) 
     2238      { 
     2239      $this->db->query( 
     2240        "UPDATE ".get_table_name('cache')." 
     2241         SET    created=". $this->db->now().", data=? 
     2242         WHERE  user_id=? 
     2243         AND    cache_key=?", 
     2244        $data, 
     2245        $_SESSION['user_id'], 
     2246        'IMAP.'.$key); 
     2247      } 
     2248    // add new cache record 
     2249    else 
     2250      { 
     2251      $this->db->query( 
     2252        "INSERT INTO ".get_table_name('cache')." 
     2253         (created, user_id, cache_key, data) 
     2254         VALUES (".$this->db->now().", ?, ?, ?)", 
     2255        $_SESSION['user_id'], 
     2256        'IMAP.'.$key, 
     2257        $data); 
     2258 
     2259      // get cache entry ID for this key 
    22392260      $sql_result = $this->db->query( 
    22402261        "SELECT cache_id 
     
    22452266        'IMAP.'.$key); 
    22462267                                      
    2247       if ($sql_arr = $this->db->fetch_assoc($sql_result)) 
    2248         $this->cache_keys[$key] = $sql_arr['cache_id']; 
    2249       else 
    2250         $this->cache_keys[$key] = FALSE; 
    2251       } 
    2252  
    2253     // update existing cache record 
    2254     if ($this->cache_keys[$key]) 
    2255       { 
    2256       $this->db->query( 
    2257         "UPDATE ".get_table_name('cache')." 
    2258          SET    created=". $this->db->now().", data=? 
    2259          WHERE  user_id=? 
    2260          AND    cache_key=?", 
    2261         $data, 
    2262         $_SESSION['user_id'], 
    2263         'IMAP.'.$key); 
    2264       } 
    2265     // add new cache record 
    2266     else 
    2267       { 
    2268       $this->db->query( 
    2269         "INSERT INTO ".get_table_name('cache')." 
    2270          (created, user_id, cache_key, data) 
    2271          VALUES (".$this->db->now().", ?, ?, ?)", 
    2272         $_SESSION['user_id'], 
    2273         'IMAP.'.$key, 
    2274         $data); 
     2268        if ($sql_arr = $this->db->fetch_assoc($sql_result)) 
     2269          $this->cache_keys[$key] = $sql_arr['cache_id']; 
    22752270      } 
    22762271    } 
     
    22872282      $_SESSION['user_id'], 
    22882283      'IMAP.'.$key); 
     2284       
     2285    unset($this->cache_keys[$key]); 
    22892286    } 
    22902287 
Note: See TracChangeset for help on using the changeset viewer.