diff options
author | thomascube <thomas@roundcube.net> | 2005-10-03 21:20:42 +0000 |
---|---|---|
committer | thomascube <thomas@roundcube.net> | 2005-10-03 21:20:42 +0000 |
commit | 6dc0269fcc9f11fbd53da1fb647237ab73cf394d (patch) | |
tree | 02976623a072f82d42a5b0943e8b4f2a7a8971da | |
parent | adf95dde7bb32716d4152528a1c6d8eab3fadcb2 (diff) |
Make message caching configurable
-rw-r--r-- | config/main.inc.php.dist | 4 | ||||
-rw-r--r-- | program/include/main.inc | 6 | ||||
-rw-r--r-- | program/include/rcube_imap.inc | 21 |
3 files changed, 23 insertions, 8 deletions
diff --git a/config/main.inc.php.dist b/config/main.inc.php.dist index 6498e019e..86f07781c 100644 --- a/config/main.inc.php.dist +++ b/config/main.inc.php.dist @@ -18,6 +18,10 @@ $rcmail_config = array(); // system error reporting: 1 = log; 2 = report (not implemented yet), 4 = show, 8 = trace $rcmail_config['debug_level'] = 5; +// enable caching of messages and mailbox data in the local database. +// this is recommended if the IMAP server does not run on the same machine +$rcmail_config['enable_caching'] = TRUE; + // automatically create a new user when log-in the first time // set to false if only registered users can use this service $rcmail_config['auto_create_user'] = TRUE; diff --git a/program/include/main.inc b/program/include/main.inc index 7b34bf632..7173917d4 100644 --- a/program/include/main.inc +++ b/program/include/main.inc @@ -132,9 +132,13 @@ function rcmail_auth_hash($sess_id, $ts) function rcmail_imap_init($connect=FALSE) { global $CONFIG, $IMAP; - + $IMAP = new rcube_imap(); + // enable caching of imap data + if ($CONFIG['enable_caching']===TRUE) + $IMAP->set_caching(TRUE); + // set root dir from config if (strlen($CONFIG['imap_root'])) $IMAP->set_rootdir($CONFIG['imap_root']); diff --git a/program/include/rcube_imap.inc b/program/include/rcube_imap.inc index b5eba0094..e74321418 100644 --- a/program/include/rcube_imap.inc +++ b/program/include/rcube_imap.inc @@ -35,7 +35,7 @@ class rcube_imap var $mailbox = 'INBOX'; var $list_page = 1; var $page_size = 10; - var $cacheing_enabled = FALSE; + var $caching_enabled = FALSE; var $default_folders = array('inbox', 'drafts', 'sent', 'junk', 'trash'); var $cache = array(); var $cache_changes = array(); @@ -46,8 +46,7 @@ class rcube_imap // PHP 5 constructor function __construct() { - if (function_exists('rcube_read_cache')) - $this->cacheing_enabled = TRUE; + } // PHP 4 compatibility @@ -681,14 +680,22 @@ class rcube_imap /* -------------------------------- - * internal cacheing functions + * internal caching functions * --------------------------------*/ - + + + function set_caching($set) + { + if ($set && function_exists('rcube_read_cache')) + $this->caching_enabled = TRUE; + else + $this->caching_enabled = FALSE; + } function get_cache($key) { // read cache - if (!isset($this->cache[$key]) && $this->cacheing_enabled) + if (!isset($this->cache[$key]) && $this->caching_enabled) { $cache_data = rcube_read_cache('IMAP.'.$key); $this->cache[$key] = strlen($cache_data) ? unserialize($cache_data) : FALSE; @@ -708,7 +715,7 @@ class rcube_imap function write_cache() { - if ($this->cacheing_enabled && $this->cache_changed) + if ($this->caching_enabled && $this->cache_changed) { foreach ($this->cache as $key => $data) { |