summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authoralecpl <alec@alec.pl>2009-09-24 12:08:23 +0000
committeralecpl <alec@alec.pl>2009-09-24 12:08:23 +0000
commit38bf4253fb6f67d655ea119ee97fff492e84177a (patch)
tree0f4aa27719e66fc61ca879750cd8162b91542a8b
parent9e2a7afc9c0ca09ab9c46ba2868787a55f9a0158 (diff)
- Fix cache status checking + improve cache operations performance (#1486104)
-rw-r--r--CHANGELOG1
-rw-r--r--program/include/rcube_imap.php39
2 files changed, 19 insertions, 21 deletions
diff --git a/CHANGELOG b/CHANGELOG
index 65aa16b36..91da12077 100644
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -1,6 +1,7 @@
CHANGELOG RoundCube Webmail
===========================
+- Fix cache status checking + improve cache operations performance (#1486104)
- Prevent from setting INBOX as any of special folders (#1486114)
- Fix regular expression for e-mail address (#1486152)
- Fix Received header format
diff --git a/program/include/rcube_imap.php b/program/include/rcube_imap.php
index 96a4a6565..bfe284544 100644
--- a/program/include/rcube_imap.php
+++ b/program/include/rcube_imap.php
@@ -485,7 +485,6 @@ class rcube_imap
*/
private function _messagecount($mailbox='', $mode='ALL', $force=FALSE)
{
- $a_mailbox_cache = FALSE;
$mode = strtoupper($mode);
if (empty($mailbox))
@@ -2140,8 +2139,8 @@ class rcube_imap
*/
function get_cache($key)
{
- // read cache
- if (!isset($this->cache[$key]) && $this->caching_enabled)
+ // read cache (if it was not read before)
+ if (!count($this->cache) && $this->caching_enabled)
{
return $this->_read_cache_record($key);
}
@@ -2218,7 +2217,8 @@ class rcube_imap
{
$sql_key = preg_replace('/^IMAP\./', '', $sql_arr['cache_key']);
$this->cache_keys[$sql_key] = $sql_arr['cache_id'];
- $this->cache[$sql_key] = $sql_arr['data'] ? unserialize($sql_arr['data']) : FALSE;
+ if (!isset($this->cache[$sql_key]))
+ $this->cache[$sql_key] = $sql_arr['data'] ? unserialize($sql_arr['data']) : FALSE;
}
}
@@ -2233,23 +2233,6 @@ class rcube_imap
if (!$this->db)
return FALSE;
- // check if we already have a cache entry for this key
- if (!isset($this->cache_keys[$key]))
- {
- $sql_result = $this->db->query(
- "SELECT cache_id
- FROM ".get_table_name('cache')."
- WHERE user_id=?
- AND cache_key=?",
- $_SESSION['user_id'],
- 'IMAP.'.$key);
-
- if ($sql_arr = $this->db->fetch_assoc($sql_result))
- $this->cache_keys[$key] = $sql_arr['cache_id'];
- else
- $this->cache_keys[$key] = FALSE;
- }
-
// update existing cache record
if ($this->cache_keys[$key])
{
@@ -2272,6 +2255,18 @@ class rcube_imap
$_SESSION['user_id'],
'IMAP.'.$key,
$data);
+
+ // get cache entry ID for this key
+ $sql_result = $this->db->query(
+ "SELECT cache_id
+ FROM ".get_table_name('cache')."
+ WHERE user_id=?
+ AND cache_key=?",
+ $_SESSION['user_id'],
+ 'IMAP.'.$key);
+
+ if ($sql_arr = $this->db->fetch_assoc($sql_result))
+ $this->cache_keys[$key] = $sql_arr['cache_id'];
}
}
@@ -2286,6 +2281,8 @@ class rcube_imap
AND cache_key=?",
$_SESSION['user_id'],
'IMAP.'.$key);
+
+ unset($this->cache_keys[$key]);
}