In this code in func.inc, it looks like RC is caching a message both to the database and to the local temp directory. Why does it cache 2 times?
// let's cache the message body within the database if ($CONFIG['enable_caching'] && $cached && ($CONFIG['db_max_length'] -300) > $headers->size) { $DB->query("UPDATE ".get_table_name('messages')." SET body=? WHERE user_id=? AND cache_key=? AND uid=?", $msg_source, $_SESSION['user_id'], $cache_key, $uid);
return $msg_source;
}
// create dir for caching if (!is_dir($cache_dir)) $dir = mkdir($cache_dir); else $dir = true;
// attempt to write a file with the message body if ($dir && ($fp = fopen($cache_path, 'w'))) { fwrite($fp, $msg_source); fclose($fp); } else { raise_error(array('code' => 403, 'type' => 'php', 'line' => __LINE__, 'file' => __FILE__, 'message' => "Failed to write to temp dir"), TRUE, FALSE); }
return $msg_source;
On Wed, 7 Dec 2005 13:31:25 -0500, Geuis Teses geuis.teses@gmail.com wrote:
In this code in func.inc, it looks like RC is caching a message both to the database and to the local temp directory. Why does it cache 2 times?
// let's cache the message body within the database if ($CONFIG['enable_caching'] && $cached && ($CONFIG['db_max_length'] -300) > $headers->size) { $DB->query("UPDATE ".get_table_name('messages')." SET body=? WHERE user_id=? AND cache_key=? AND uid=?", $msg_source, $_SESSION['user_id'], $cache_key, $uid);
return $msg_source; }
// create dir for caching if (!is_dir($cache_dir)) $dir = mkdir($cache_dir); else $dir = true;
Strange, I had a post on this weeks back and it was commented that since I (and likely most) are running IMAP/MySQL on the same server having enable_caching wouldnt' provide any benefit. It seems that there should be another variable like: if ($CONFIG['enable_fscaching'] to handle filesystem caching - then you could select one within main.inc. I would recommend defaulting to the fs version. Comments?
http://fak3r.com - you don't have to kick it
If you have a closer look at the code, you would see, that the message is not cached twice but it is decided where to cache it.
For caching messages with large attachments we run into problems when writing them to the database for caching. Therefore RC creates a temp file with the message content. For smaller messages RC still uses the database for faster access. The size limit (usually what max_packet_size is set to in MySQL databases) can be configured.
Regards, Thomas
Geuis Teses wrote:
In this code in func.inc, it looks like RC is caching a message both to the database and to the local temp directory. Why does it cache 2 times?
[...]