From: Eloi G. <el...@re...> - 2006-03-10 06:48:18
|
Hi all! I'd stopped using the phpws cache a couple years ago because of the extraordinary amount of disk accesses generated. Even with GLOBAL_CACHE on, server load was still higher than without the cache. It was only recently when I started exploring file-based caching for Article Manager that I found out why. What PHPWS_Template::processTemplate does is load the cached completed template for that particular set of data *AFTER* that data was already read and prepared by the script! This is essentially 2 reads on the same data, which is opposite to what the cache is intended to do. Furthermore, if a single variable in the data is different, a new INSERT is sent to the db server. All this for a small .tpl file that only wants to be read once and stored in memory for the rest of the pageview! I think the solution to this would be to use GLOBAL_CACHE exclusively for this, and to index only the template name, not a md5 hash of the entire record. GLOBAL_CACHE should be for items that don't need to be cached past the pageview, like repetitively-used templates. As such, it should be a separate caching call (PHPWS_Cache::set_global) so that these items don't clutter up the normal caching space. For all other items, the regular caching calls (PHPWS_Cache::set) should let you choose between file- or database- based caching. The reason for this is that database-based caching is only better if you have premium hardware acting as a dedicated db server, or if you have one database backend and multiple webserver frontends. This is the opposite of the hardware that 98% of phpws installs are running on. So what I'd like to do is introduce an option for file-based caching. Most likely using the PEAR Cache_Lite class (http://pear.php.net/manual/en/package.caching.cache-lite.intro.php) or phpCache (http://0x00.org/php/phpCache/). So, before I start coding, I'd like to hear what you guys think -- good/bad idea? Any suggestions for a better way to handle caching? Questions? -Eloi- |