Changeset b32cb21 in github
- Timestamp:
- Jun 23, 2009 3:17:49 AM (4 years ago)
- Branches:
- master, HEAD, courier-fix, dev-browser-capabilities, pdo, release-0.6, release-0.7, release-0.8
- Children:
- ac62299
- Parents:
- ad84f9c
- File:
-
- 1 edited
-
program/include/rcube_imap.php (modified) (13 diffs)
Legend:
- Unmodified
- Added
- Removed
-
program/include/rcube_imap.php
rad84f9c rb32cb21 1546 1546 1547 1547 // reload message headers if cached 1548 $cache_key = $mailbox.'.msg';1549 1548 if ($this->caching_enabled) 1550 1549 { 1550 $cache_key = $mailbox.'.msg'; 1551 1551 $this->remove_message_cache($cache_key, $uids); 1552 1552 … … 1648 1648 // update cached message headers 1649 1649 $cache_key = $from_mbox.'.msg'; 1650 if ($moved && ($a_cache_index = $this->get_message_cache_index($cache_key))) 1651 { 1652 $start_index = 100000; 1653 foreach ($a_uids as $uid) 1654 { 1655 if (($index = array_search($uid, $a_cache_index)) !== FALSE) 1656 $start_index = min($index, $start_index); 1657 } 1658 1650 if ($moved && $start_index = $this->get_message_cache_index_min($cache_key, $a_uids)) { 1659 1651 // clear cache from the lowest index on 1660 if ($start_index < 100000) 1661 $this->clear_message_cache($cache_key, $start_index); 1652 $this->clear_message_cache($cache_key, $start_index); 1662 1653 } 1663 1654 … … 1704 1695 // remove deleted messages from cache 1705 1696 $cache_key = $mailbox.'.msg'; 1706 if ($deleted && ($a_cache_index = $this->get_message_cache_index($cache_key))) 1707 { 1708 $start_index = 100000; 1709 foreach ($a_uids as $uid) 1710 { 1711 if (($index = array_search($uid, $a_cache_index)) !== FALSE) 1712 $start_index = min($index, $start_index); 1713 } 1714 1697 if ($deleted && $start_index = $this->get_message_cache_index_min($cache_key, $a_uids)) { 1715 1698 // clear cache from the lowest index on 1716 if ($start_index < 100000) 1717 $this->clear_message_cache($cache_key, $start_index); 1699 $this->clear_message_cache($cache_key, $start_index); 1718 1700 } 1719 1701 … … 2060 2042 if (!isset($this->cache[$key]) && $this->caching_enabled) 2061 2043 { 2062 $cache_data = $this->_read_cache_record('IMAP.'.$key); 2063 $this->cache[$key] = strlen($cache_data) ? unserialize($cache_data) : FALSE; 2044 return $this->_read_cache_record($key); 2064 2045 } 2065 2046 … … 2087 2068 { 2088 2069 if ($this->cache_changes[$key]) 2089 $this->_write_cache_record( 'IMAP.'.$key, serialize($data));2070 $this->_write_cache_record($key, serialize($data)); 2090 2071 } 2091 2072 } … … 2103 2084 { 2104 2085 foreach ($this->cache as $key => $data) 2105 $this->_clear_cache_record( 'IMAP.'.$key);2086 $this->_clear_cache_record($key); 2106 2087 2107 2088 $this->cache = array(); … … 2111 2092 else 2112 2093 { 2113 $this->_clear_cache_record( 'IMAP.'.$key);2094 $this->_clear_cache_record($key); 2114 2095 $this->cache_changes[$key] = FALSE; 2115 2096 unset($this->cache[$key]); … … 2122 2103 function _read_cache_record($key) 2123 2104 { 2124 $cache_data = FALSE;2125 2126 2105 if ($this->db) 2127 2106 { 2128 2107 // get cached data from DB 2129 2108 $sql_result = $this->db->query( 2130 "SELECT cache_id, data 2109 "SELECT cache_id, data, cache_key 2131 2110 FROM ".get_table_name('cache')." 2132 2111 WHERE user_id=? 2133 AND cache_key=?", 2134 $_SESSION['user_id'], 2135 $key); 2136 2137 if ($sql_arr = $this->db->fetch_assoc($sql_result)) 2112 AND cache_key LIKE 'IMAP.%'", 2113 $_SESSION['user_id']); 2114 2115 while ($sql_arr = $this->db->fetch_assoc($sql_result)) 2138 2116 { 2139 $cache_data = $sql_arr['data']; 2140 $this->cache_keys[$key] = $sql_arr['cache_id']; 2117 $sql_key = preg_replace('/^IMAP\./', '', $sql_arr['cache_key']); 2118 $this->cache_keys[$sql_key] = $sql_arr['cache_id']; 2119 $this->cache[$sql_key] = $sql_arr['data'] ? unserialize($sql_arr['data']) : FALSE; 2141 2120 } 2142 2121 } 2143 2122 2144 return $ cache_data;2123 return $this->cache[$key]; 2145 2124 } 2146 2125 … … 2162 2141 AND cache_key=?", 2163 2142 $_SESSION['user_id'], 2164 $key);2143 'IMAP.'.$key); 2165 2144 2166 2145 if ($sql_arr = $this->db->fetch_assoc($sql_result)) … … 2180 2159 $data, 2181 2160 $_SESSION['user_id'], 2182 $key);2161 'IMAP.'.$key); 2183 2162 } 2184 2163 // add new cache record … … 2190 2169 VALUES (".$this->db->now().", ?, ?, ?)", 2191 2170 $_SESSION['user_id'], 2192 $key,2171 'IMAP.'.$key, 2193 2172 $data); 2194 2173 } … … 2205 2184 AND cache_key=?", 2206 2185 $_SESSION['user_id'], 2207 $key);2186 'IMAP.'.$key); 2208 2187 } 2209 2188 … … 2463 2442 } 2464 2443 2465 2444 /** 2445 * @access private 2446 */ 2447 function get_message_cache_index_min($key, $uids=NULL) 2448 { 2449 if (!$this->caching_enabled) 2450 return; 2451 2452 $sql_result = $this->db->query( 2453 "SELECT MIN(idx) AS minidx 2454 FROM ".get_table_name('messages')." 2455 WHERE user_id=? 2456 AND cache_key=?" 2457 .(!empty($uids) ? " AND uid IN (".$this->db->array2list($uids, 'integer').")" : ''), 2458 $_SESSION['user_id'], 2459 $key); 2460 2461 if ($sql_arr = $this->db->fetch_assoc($sql_result)) 2462 return $sql_arr['minidx']; 2463 else 2464 return 0; 2465 } 2466 2466 2467 2467
Note: See TracChangeset
for help on using the changeset viewer.
