Changeset 4785 in subversion
- Timestamp:
- May 18, 2011 8:37:00 AM (2 years ago)
- Location:
- trunk/roundcubemail
- Files:
-
- 5 edited
-
CHANGELOG (modified) (1 diff)
-
config/main.inc.php.dist (modified) (1 diff)
-
program/include/rcmail.php (modified) (1 diff)
-
program/include/rcube_cache.php (modified) (6 diffs)
-
program/include/rcube_imap.php (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
trunk/roundcubemail/CHANGELOG
r4783 r4785 2 2 =========================== 3 3 4 - Added general rcube_cache class with memcachesupport4 - Added general rcube_cache class with Memcache and APC support 5 5 - Improved caching performance by skipping writes of unchanged data 6 6 - Option enable_caching replaced by imap_cache and messages_cache options -
trunk/roundcubemail/config/main.inc.php.dist
r4783 r4785 110 110 $rcmail_config['imap_auth_pw'] = null; 111 111 112 // Type of IMAP indexes cache. Supported values: 'db' and 'memcache'.112 // Type of IMAP indexes cache. Supported values: 'db', 'apc' and 'memcache'. 113 113 $rcmail_config['imap_cache'] = null; 114 114 -
trunk/roundcubemail/program/include/rcmail.php
r4783 r4785 357 357 * 358 358 * @param string $name Cache identifier 359 * @param string $type Cache type ('db' or 'memcache')359 * @param string $type Cache type ('db', 'apc' or 'memcache') 360 360 * 361 361 * @return rcube_cache Cache object -
trunk/roundcubemail/program/include/rcube_cache.php
r4784 r4785 52 52 * Object constructor. 53 53 * 54 * @param string $type Engine type ('db' or 'memcache' )54 * @param string $type Engine type ('db' or 'memcache' or 'apc') 55 55 * @param int $userid User identifier 56 56 * @param string $prefix Key name prefix … … 59 59 { 60 60 $rcmail = rcmail::get_instance(); 61 $type = strtolower($type); 61 62 62 if ( strtolower($type)== 'memcache') {63 if ($type == 'memcache') { 63 64 $this->type = 'memcache'; 64 65 $this->db = $rcmail->get_memcache(); 66 } 67 else if ($type == 'apc') { 68 $this->type = 'apc'; 69 $this->db = function_exists('apc_exists'); // APC 3.1.4 required 65 70 } 66 71 else { … … 209 214 210 215 if ($this->type == 'memcache') { 211 $data = $this->db->get($this->mc_key($key)); 216 $data = $this->db->get($this->ckey($key)); 217 218 if ($data) { 219 $this->cache_sums[$key] = md5($data); 220 $data = unserialize($data); 221 } 222 return $this->cache[$key] = $data; 223 } 224 225 if ($this->type == 'apc') { 226 $data = apc_fetch($this->ckey($key)); 212 227 213 228 if ($data) { … … 264 279 265 280 if ($this->type == 'memcache') { 266 $key = $this-> mc_key($key);281 $key = $this->ckey($key); 267 282 $result = $this->db->replace($key, $data, MEMCACHE_COMPRESSED); 268 283 if (!$result) 269 284 $result = $this->db->set($key, $data, MEMCACHE_COMPRESSED); 270 285 return $result; 286 } 287 288 if ($this->type == 'apc') { 289 $key = $this->ckey($key); 290 if (apc_exists($key)) 291 apc_delete($key); 292 return apc_store($key, $data); 271 293 } 272 294 … … 315 337 316 338 if ($this->type == 'memcache') { 317 return $this->db->delete($this->mc_key($key)); 339 return $this->db->delete($this->ckey($key)); 340 } 341 342 if ($this->type == 'apc') { 343 return apc_delete($this->ckey($key)); 318 344 } 319 345 … … 329 355 330 356 /** 331 * Creates per-user Memcache key357 * Creates per-user cache key (for memcache and apc) 332 358 * 333 359 * @param string $key Cache key 334 360 * @access private 335 361 */ 336 private function mc_key($key)362 private function ckey($key) 337 363 { 338 364 return sprintf('[%d]%s', $this->userid, $key); -
trunk/roundcubemail/program/include/rcube_imap.php
r4783 r4785 3739 3739 * Enable or disable indexes caching 3740 3740 * 3741 * @param boolean $type Cache type ( memcache' or 'db')3741 * @param boolean $type Cache type (@see rcmail::get_cache) 3742 3742 * @access public 3743 3743 */
Note: See TracChangeset
for help on using the changeset viewer.
