Index: engines/apc.php =================================================================== RCS file: /cvs/drupal-contrib/contributions/modules/cacherouter/engines/apc.php,v retrieving revision 1.3 diff -u -p -r1.3 apc.php --- engines/apc.php 2 Jun 2008 01:50:13 -0000 1.3 +++ engines/apc.php 4 Jun 2008 10:07:47 -0000 @@ -10,7 +10,7 @@ class apcCache extends Cache { function page_fast_cache() { return TRUE; } - + /** * get() * Return item from cache if it is available. @@ -25,7 +25,7 @@ class apcCache extends Cache { if (isset($cache)) { return $cache; } - + $cache = apc_fetch($this->key($key)); if (is_object($cache) && $cache->serialized) { $cache->data = unserialize($cache->data); @@ -49,7 +49,7 @@ class apcCache extends Cache { * @return bool * Returns TRUE on success or FALSE on failure */ - function set($key, $value, $expire = CACHE_PERMENANT, $headers = NULL) { + function set($key, $value, $expire = CACHE_PERMANENT, $headers = NULL) { if ($expire == CACHE_TEMPORARY) { $expire = 180; } @@ -64,7 +64,7 @@ class apcCache extends Cache { $cache->serialized = TRUE; $cache->data = serialize($value); } - else { + else { $cache->serialized = FALSE; $cache->data = $value; } @@ -101,7 +101,7 @@ class apcCache extends Cache { return $return; } - + /** * delete() * Remove item from cache. @@ -114,14 +114,14 @@ class apcCache extends Cache { function delete($key) { // Remove from static array cache. parent::delete($key); - + if (substr($key, -1, 1) == '*') { $key = substr($key, 0, strlen($key) - 1); $lookup = apc_fetch($this->lookup); foreach ($lookup as $k => $v) { if (substr($k, 0, strlen($key) - 1)) { apc_delete($k); - unset($lookup[$k]); + unset($lookup[$k]); } } $this->lock(); @@ -211,7 +211,7 @@ class apcCache extends Cache { } return TRUE; } - + /** * unlock() * lock the cache from other writes. Index: engines/db.php =================================================================== RCS file: /cvs/drupal-contrib/contributions/modules/cacherouter/engines/db.php,v retrieving revision 1.2 diff -u -p -r1.2 db.php --- engines/db.php 2 Jun 2008 01:30:08 -0000 1.2 +++ engines/db.php 4 Jun 2008 10:07:48 -0000 @@ -1,22 +1,22 @@ content[$key])) { return $this->content[$key]; } - + // Handle garbage collection $this->gc(); - + $cache = db_fetch_object(db_query("SELECT data, created, headers, expire, serialized FROM {". $this->name ."} WHERE cid = '%s'", $key)); if (isset($cache->data)) { // If the data is permanent or we're not enforcing a minimum cache lifetime @@ -49,8 +49,8 @@ class dbCache extends Cache { } return 0; } - - function set($key, $value, $expire = CACHE_PERMENANT, $headers = NULL) { + + function set($key, $value, $expire = CACHE_PERMANENT, $headers = NULL) { unset($this->content[$key]); $serialized = 0; if (is_object($value) || is_array($value)) { @@ -63,10 +63,10 @@ class dbCache extends Cache { @db_query("INSERT INTO {". $this->name ."} (cid, data, created, expire, headers, serialized) VALUES ('%s', %b, %d, %d, '%s', %d)", $key, $value, $created, $expire, $headers, $serialized); } } - + function delete($key) { - unset($this->content[$key]); if (substr($key, -1, 1) == '*') { + $this->content = array(); if ($key == '*') { db_query("DELETE FROM {". $this->name ."}"); } @@ -76,20 +76,19 @@ class dbCache extends Cache { } } else { + unset($this->content[$key]); db_query("DELETE FROM {". $this->name ."} WHERE cid = '%s'", $key); } } - - function flush() { - $this->content = array(); - db_query("DELETE FROM {". $this->name ."} WHERE expire != %d AND expire < %d", CACHE_PERMANENT, time()); - } - function flush($flush) { + function flush($flush = NULL) { + if (is_null($flush)) { + $flush = time(); + } $this->content = array(); db_query("DELETE FROM {". $this->name ."} WHERE expire != %d AND expire < %d", CACHE_PERMANENT, $flush); } - + function gc() { // Garbage collection necessary when enforcing a minimum cache lifetime $cache_flush = variable_get('cache_flush', 0); Index: engines/eacc.php =================================================================== RCS file: /cvs/drupal-contrib/contributions/modules/cacherouter/engines/eacc.php,v retrieving revision 1.1 diff -u -p -r1.1 eacc.php --- engines/eacc.php 2 Jun 2008 01:30:08 -0000 1.1 +++ engines/eacc.php 4 Jun 2008 10:07:48 -0000 @@ -49,7 +49,7 @@ class eaccCache extends Cache { * @return bool * Returns TRUE on success or FALSE on failure */ - function set($key, $value, $expire = CACHE_PERMENANT, $headers = NULL) { + function set($key, $value, $expire = CACHE_PERMANENT, $headers = NULL) { if ($expire == CACHE_TEMPORARY) { $expire = 180; } @@ -64,7 +64,7 @@ class eaccCache extends Cache { $cache->serialized = TRUE; $cache->data = serialize($value); } - else { + else { $cache->serialized = FALSE; $cache->data = $value; } Index: engines/file.php =================================================================== RCS file: /cvs/drupal-contrib/contributions/modules/cacherouter/engines/file.php,v retrieving revision 1.1 diff -u -p -r1.1 file.php --- engines/file.php 31 Mar 2008 08:40:50 -0000 1.1 +++ engines/file.php 4 Jun 2008 10:07:48 -0000 @@ -3,25 +3,25 @@ define('FASTPATH_FSCACHE_PATH', '/tmp/fi class fileCache extends Cache { var $content = array(); - + function page_fast_cache() { return TRUE; } - + function get($key) { global $user; - + if (isset($this->content[$key])) { return $this->content[$key]; } - + $cache_lifetime = variable_get('cache_lifetime', 0); if (variable_get('page_cache_fastpath', 0)) { $cache = NULL; $cache_file = $this->key($key); - if (file_exists($cache_file)) { + if (file_exists($cache_file)) { if ($fp = fopen($cache_file, 'r')) { if (flock($fp, LOCK_SH)) { $data = fread($fp, filesize($cache_file)); @@ -56,8 +56,8 @@ class fileCache extends Cache { } return FALSE; } - - function set($key, $value, $expire = CACHE_PERMENANT, $headers = NULL) { + + function set($key, $value, $expire = CACHE_PERMANENT, $headers = NULL) { static $subdirectories; if (variable_get('page_cache_fastpath', 0)) { @@ -69,9 +69,9 @@ class fileCache extends Cache { $cache->expire = $expire; $cache->headers = $headers; $cache->data = $value; - + $data = serialize($cache); - + $file = $this->key($key); if ($fp = @fopen($file, 'w')) { // only write to the cache file if we can obtain an exclusive lock @@ -87,7 +87,7 @@ class fileCache extends Cache { } } } - + function delete($key) { $file = $this->key($key); if ($fp = fopen($file, 'w')) { @@ -98,18 +98,18 @@ class fileCache extends Cache { } } } - + function flush() { global $user; - + $table = $this->name; $file_cache = variable_get('file_cache', FASTPATH_FSCACHE_PATH); $cache_lifetime = variable_get('cache_lifetime', 0); $fspath = variable_get('file_cache', FASTPATH_FSCACHE_PATH); - + $ivalfrom = ord("a"); $ivalto = ord("f"); - + for ($i = $ivalfrom; $i <= $ivalto; $i++) { $this->purge("$fspath/$table/". chr($i)); } @@ -118,26 +118,26 @@ class fileCache extends Cache { $this->purge("$fspath/$table/". $i); } } - + function key($key) { $table = $this->name; $fspath = variable_get('file_cache', FASTPATH_FSCACHE_PATH); $hash = md5($key); - + $this->create_directory($fspath, $hash{0}); - + return "$fspath/$table/". $hash{0}. '/'. $hash; } - + /** * Create the necessary $table directory and/or letter/number subdirectory if - * it doesn't exist. We store the directories we've created in a static + * it doesn't exist. We store the directories we've created in a static * so we don't bother doing an fstat on that more than one time per page load. */ function create_directory($fspath, $hash) { static $dirs = array(); $table = $this->name; - + $create = array($fspath, "$fspath/$table", "$fspath/$table/$hash"); foreach ($create as $dir) { Index: engines/memcache.php =================================================================== RCS file: /cvs/drupal-contrib/contributions/modules/cacherouter/engines/memcache.php,v retrieving revision 1.2 diff -u -p -r1.2 memcache.php --- engines/memcache.php 2 Jun 2008 01:30:08 -0000 1.2 +++ engines/memcache.php 4 Jun 2008 10:07:48 -0000 @@ -2,11 +2,11 @@ class memcacheCache extends Cache { var $settings = array(); var $memcache; - + function page_fast_cache() { return TRUE; } - + function __construct($bin) { global $conf; // Assign the servers on the following order: bin specific -> default specific -> localhost port 11211 @@ -29,33 +29,33 @@ class memcacheCache extends Cache { $this->settings['shared'] = TRUE; } } - + parent::__construct($bin); - + $this->connect(); } - + function get($key) { // Attempt to pull from static cache. $cache = parent::get($key); if (isset($cache)) { return $cache; } - + // Get from memcache $cache = $this->memcache->get($this->key($key)); - - // Update static cache + + // Update static cache parent::set($key, $cache); - + return $cache; } - - function set($key, $value, $expire = CACHE_PERMENANT, $headers = NULL) { + + function set($key, $value, $expire = CACHE_PERMANENT, $headers = NULL) { if ($expire == CACHE_TEMPORARY) { $expire = 180; } - + // Create new cache object. $cache = new stdClass; $cache->cid = $key; @@ -63,7 +63,7 @@ class memcacheCache extends Cache { $cache->expire = $expire; $cache->headers = $headers; $cache->data = $value; - + if (!empty($key) && !empty($value)) { if ($this->settings['shared']) { $this->lock(); @@ -92,7 +92,7 @@ class memcacheCache extends Cache { } // Resave the lookup table (even on failure) - $this->memcache->set($this->lookup, $lookup, $this->settings['compress'], $expire); + $this->memcache->set($this->lookup, $lookup, $this->settings['compress'], $expire); // Remove lock. $this->unlock(); @@ -103,20 +103,20 @@ class memcacheCache extends Cache { } } } - + function delete($key) { // Delete from static cache parent::delete($key); - + // Remove from memcache. return $this->memcache->delete($this->key($key)); } - + function flush() { // Flush static cache parent::flush(); - + // If this is a shared cache, we need to cycle through the lookup table and remove individual // items directly if ($this->settings['shared']) { @@ -149,7 +149,7 @@ class memcacheCache extends Cache { return $this->memcache->flush(); } } - + function lock() { // Lock once by trying to add lock file, if we can't get the lock, we will loop // for 3 seconds attempting to get lock. If we still can't get it at that point, @@ -164,11 +164,11 @@ class memcacheCache extends Cache { } return TRUE; } - + function unlock() { return $this->memcache->delete($this->lock); } - + function connect() { $this->memcache =& new Memcache; foreach ($this->settings['servers'] as $server) { @@ -178,7 +178,7 @@ class memcacheCache extends Cache { } } } - + function close() { $this->memcache->close(); } Index: engines/xcache.php =================================================================== RCS file: /cvs/drupal-contrib/contributions/modules/cacherouter/engines/xcache.php,v retrieving revision 1.3 diff -u -p -r1.3 xcache.php --- engines/xcache.php 2 Jun 2008 01:50:13 -0000 1.3 +++ engines/xcache.php 4 Jun 2008 10:07:48 -0000 @@ -10,7 +10,7 @@ class xcacheCache extends Cache { function page_fast_cache() { return TRUE; } - + /** * get() * Return item from cache if it is available. @@ -25,13 +25,13 @@ class xcacheCache extends Cache { if (isset($cache)) { return $cache; } - - // Get item from cache + + // Get item from cache $cache = xcache_get($this->key($key)); // Update static cache parent::set($key, $cache); - + return $cache; } @@ -50,7 +50,7 @@ class xcacheCache extends Cache { * @return bool * Returns TRUE on success or FALSE on failure */ - function set($key, $value, $expire = CACHE_PERMENANT, $headers = NULL) { + function set($key, $value, $expire = CACHE_PERMANENT, $headers = NULL) { if ($expire == CACHE_TEMPORARY) { $expire = 180; } @@ -65,7 +65,7 @@ class xcacheCache extends Cache { $cache->serialized = TRUE; $cache->data = serialize($value); } - else { + else { $cache->serialized = FALSE; $cache->data = $value; } @@ -102,7 +102,7 @@ class xcacheCache extends Cache { return $return; } - + /** * delete() * Remove item from cache. @@ -115,14 +115,14 @@ class xcacheCache extends Cache { function delete($key) { // Remove from static array cache. parent::delete($key); - + if (substr($key, -1, 1) == '*') { $key = substr($key, 0, strlen($key) - 1); $lookup = xcache_get($this->lookup); foreach ($lookup as $k => $v) { if (substr($k, 0, strlen($key) - 1)) { xcache_unset($k); - unset($lookup[$k]); + unset($lookup[$k]); } } $this->lock(); @@ -201,7 +201,7 @@ class xcacheCache extends Cache { xcache_set($this->lock, TRUE); return TRUE; } - + /** * unlock() * lock the cache from other writes. @@ -211,6 +211,6 @@ class xcacheCache extends Cache { * Returns TRUE on success, FALSE on failure */ function unlock() { - return xcache_unset($this->lock); + return xcache_unset($this->lock); } } \ No newline at end of file