Index: trunk/lib/SessionCache.inc.php
===================================================================
--- trunk/lib/SessionCache.inc.php	(revision 1)
+++ trunk/lib/SessionCache.inc.php	(revision 21)
@@ -13,4 +13,5 @@
 {
     var $_params = array(
+        'enabled' => true,
         'soft_limit' => 204800,
         'hard_limit' => 4194304,
@@ -43,4 +44,8 @@
     function setParam($params)
     {
+        if (!isset($this) || !is_a($this, 'SessionCache')) {
+            $this =& SessionCache::getInstance();
+        }
+
         if (isset($params) && is_array($params)) {
             // Merge new parameters with old overriding only those passed.
@@ -60,4 +65,8 @@
     function getParam($param)
     {
+        if (!isset($this) || !is_a($this, 'SessionCache')) {
+            $this =& SessionCache::getInstance();
+        }
+
         if (isset($this->_params[$param])) {
             return $this->_params[$param];
@@ -86,5 +95,11 @@
     function putCache($var, $var_id, $force_it_in=false)
     {
-        $cache =& SessionCache::getInstance();
+        if (!isset($this) || !is_a($this, 'SessionCache')) {
+            $this =& SessionCache::getInstance();
+        }
+
+        if (!$this->getParam('enabled')) {
+            return false;
+        }
 
         $var_id = md5($var_id);
@@ -92,11 +107,11 @@
         $serialized_var_len = strlen($serialized_var);
         
-        if ($serialized_var_len >= $cache->getParam('soft_limit') && !$force_it_in) {
-            App::logMsg(sprintf('Serialized variable (%s bytes) more than soft_limit (%s bytes).', $serialized_var_len, $cache->getParam('soft_limit')), LOG_NOTICE, __FILE__, __LINE__);
-            return false;
-        }
-        
-        if ($serialized_var_len >= $cache->getParam('hard_limit')) {
-            App::logMsg(sprintf('Serialized variable (%s bytes) more than hard_limit (%s bytes).', $serialized_var_len, $cache->getParam('hard_limit')), LOG_NOTICE, __FILE__, __LINE__);
+        if ($serialized_var_len >= $this->getParam('soft_limit') && !$force_it_in) {
+            App::logMsg(sprintf('Serialized variable (%s bytes) more than soft_limit (%s bytes).', $serialized_var_len, $this->getParam('soft_limit')), LOG_NOTICE, __FILE__, __LINE__);
+            return false;
+        }
+        
+        if ($serialized_var_len >= $this->getParam('hard_limit')) {
+            App::logMsg(sprintf('Serialized variable (%s bytes) more than hard_limit (%s bytes).', $serialized_var_len, $this->getParam('hard_limit')), LOG_NOTICE, __FILE__, __LINE__);
             return false;
         }
@@ -107,6 +122,6 @@
             unset($_SESSION['_session_cache'][$var_id]);
             // Continue to prune the cache if it's length is too long for the new variable to fit, but keep at least MIN_ITEMS at least.
-            while (strlen(serialize($_SESSION['_session_cache'])) + $serialized_var_len >= $cache->getParam('soft_limit') 
-            && sizeof($_SESSION['_session_cache']) >= $cache->getParam('min_items')) {
+            while (strlen(serialize($_SESSION['_session_cache'])) + $serialized_var_len >= $this->getParam('soft_limit') 
+            && sizeof($_SESSION['_session_cache']) >= $this->getParam('min_items')) {
                 array_shift($_SESSION['_session_cache']);
             }
@@ -133,4 +148,12 @@
     function getCache($var_id)
     {
+        if (!isset($this) || !is_a($this, 'SessionCache')) {
+            $this =& SessionCache::getInstance();
+        }
+
+        if (!$this->getParam('enabled')) {
+            return false;
+        }
+        
         $var_id = md5($var_id);
         if (isset($_SESSION['_session_cache'][$var_id])) {
@@ -155,4 +178,12 @@
     function isCached($var_id)
     {
+        if (!isset($this) || !is_a($this, 'SessionCache')) {
+            $this =& SessionCache::getInstance();
+        }
+
+        if (!$this->getParam('enabled')) {
+            return false;
+        }
+
         $var_id = md5($var_id);
         return isset($_SESSION['_session_cache'][$var_id]);
