diff --git a/workflow/engine/classes/class.fileCache.php b/workflow/engine/classes/class.fileCache.php index 316669927..04e035f0f 100644 --- a/workflow/engine/classes/class.fileCache.php +++ b/workflow/engine/classes/class.fileCache.php @@ -1,5 +1,4 @@ dir = $dir; } - private function _name ($key) + private function _name($key) { - return sprintf( "%s/%s", $this->dir, sha1( $key ) ); + return sprintf("%s%s", $this->dir, sha1($key)); } public function get ($key, $expiration = 3600) @@ -53,7 +51,7 @@ class FileCache } if (filemtime( $cache_path ) < (time() - $expiration)) { - // $this->clear($key); + // $this->delete($key); // different users can have different timeout requests return FALSE; } @@ -102,15 +100,26 @@ class FileCache return TRUE; } - public function clear ($key) + public function delete($key) { - $cache_path = $this->_name( $key ); + $cache_path = $this->_name($key); - if (file_exists( $cache_path )) { - unlink( $cache_path ); - return TRUE; + if (file_exists($cache_path)) { + unlink($cache_path); + return true; } - return FALSE; + return false; } -} \ No newline at end of file + + public function flush() + { + G::rm_dir($this->dir); + } + + public function getStats() + { + return null; + } +} + diff --git a/workflow/engine/classes/class.memcached.php b/workflow/engine/classes/class.memcached.php index 51cc4c864..49cfa3266 100644 --- a/workflow/engine/classes/class.memcached.php +++ b/workflow/engine/classes/class.memcached.php @@ -1,5 +1,4 @@ version = $this->mem->getVersion(); } } else { - require_once ('classes/class.fileCache.php'); - // create cache folder - $cacheFolder = PATH_DATA . "sites/" . $workspace . "/cachefiles/"; + require_once ("classes" . PATH_SEP . "class.fileCache.php"); + + //Create cache folder + $cacheFolder = PATH_DATA . "sites". PATH_SEP . $workspace . PATH_SEP . "cachefiles" . PATH_SEP; + if (! file_exists( $cacheFolder )) { if (! mkdir( $cacheFolder )) { return false; @@ -116,7 +117,8 @@ class PMmemcached if (! $this->connected) { return false; } - if ($this->class != 'filecache') { + + if ($this->class != "fileCache") { $this->mem->set( $this->workspace . '_' . $key, $object, false, $timeout ); } else { $this->mem->set( $this->workspace . '_' . $key, $object ); @@ -133,50 +135,61 @@ class PMmemcached public function add ($key, $value) { - if ((! $this->connected) || ($this->class == 'filecache')) { + if (!$this->connected || $this->class == "fileCache") { return false; } + return $this->mem->add( $this->workspace . '_' . $key, $value ); } public function increment ($key, $value) { - if ((! $this->connected) || ($this->class == 'filecache')) { + if (!$this->connected || $this->class == "fileCache") { return false; } + return $this->mem->increment( $this->workspace . '_' . $key, $value ); } - public function delete ($key) + public function delete($key) { - if ((! $this->connected) || ($this->class == 'filecache')) { + if (!$this->connected) { return false; } - return $this->mem->delete( $this->workspace . '_' . $key ); + + return $this->mem->delete($this->workspace . "_" . $key); } - public function flush () + public function flush() { - if ((! $this->connected) || ($this->class == 'filecache')) { + if (!$this->connected) { return false; } + return $this->mem->flush(); } - public function getStats () + public function getStats() { - if ((! $this->connected) || ($this->class == 'filecache')) { + if (!$this->connected) { return false; } + return $status = $this->mem->getStats(); } - public function printDetails () + public function printDetails() { - if ((! $this->connected) || ($this->class == 'filecache')) { + if (!$this->connected) { return false; } + $status = $this->mem->getStats(); + + if (!is_array($status)) { + return false; + } + echo "
| Memcache Server version: | " . $status["version"] . " |
| Number of hours this server has been running | " . ($status["uptime"] / 3660) . " |