Changeset 157 for branches/2.0/lib/SessionCache.inc.php
- Timestamp:
- Jun 9, 2006 9:25:54 PM (18 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/2.0/lib/SessionCache.inc.php
r53 r157 44 44 function setParam($params) 45 45 { 46 if (!isset($this) || !is_a($this, 'SessionCache') && !is_subclass_of($this, 'SessionCache')) { 47 $this =& SessionCache::getInstance(); 48 } 46 $_this =& SessionCache::getInstance(); 49 47 50 48 if (isset($params) && is_array($params)) { 51 49 // Merge new parameters with old overriding only those passed. 52 $ this->_params = array_merge($this->_params, $params);50 $_this->_params = array_merge($_this->_params, $params); 53 51 } else { 54 52 App::logMsg(sprintf('Parameters are not an array: %s', $params), LOG_ERR, __FILE__, __LINE__); … … 65 63 function getParam($param) 66 64 { 67 if (!isset($this) || !is_a($this, 'SessionCache') && !is_subclass_of($this, 'SessionCache')) { 68 $this =& SessionCache::getInstance(); 69 } 70 71 if (isset($this->_params[$param])) { 72 return $this->_params[$param]; 65 $_this =& SessionCache::getInstance(); 66 67 if (isset($_this->_params[$param])) { 68 return $_this->_params[$param]; 73 69 } else { 74 70 App::logMsg(sprintf('Parameter is not set: %s', $param), LOG_DEBUG, __FILE__, __LINE__); … … 95 91 function putCache($var, $var_id, $force_it_in=false) 96 92 { 97 if (!isset($this) || !is_a($this, 'SessionCache') && !is_subclass_of($this, 'SessionCache')) { 98 $this =& SessionCache::getInstance(); 99 } 100 101 if (!$this->getParam('enabled')) { 93 $_this =& SessionCache::getInstance(); 94 95 if (!$_this->getParam('enabled')) { 102 96 App::logMsg(sprintf('SessionCache not enabled, not saving data.', null), LOG_DEBUG, __FILE__, __LINE__); 103 97 return false; … … 108 102 $serialized_var_len = strlen($serialized_var); 109 103 110 if ($serialized_var_len >= $ this->getParam('soft_limit') && !$force_it_in) {111 App::logMsg(sprintf('Serialized variable (%s bytes) more than soft_limit (%s bytes).', $serialized_var_len, $ this->getParam('soft_limit')), LOG_NOTICE, __FILE__, __LINE__);112 return false; 113 } 114 115 if ($serialized_var_len >= $ this->getParam('hard_limit')) {116 App::logMsg(sprintf('Serialized variable (%s bytes) more than hard_limit (%s bytes).', $serialized_var_len, $ this->getParam('hard_limit')), LOG_NOTICE, __FILE__, __LINE__);104 if ($serialized_var_len >= $_this->getParam('soft_limit') && !$force_it_in) { 105 App::logMsg(sprintf('Serialized variable (%s bytes) more than soft_limit (%s bytes).', $serialized_var_len, $_this->getParam('soft_limit')), LOG_NOTICE, __FILE__, __LINE__); 106 return false; 107 } 108 109 if ($serialized_var_len >= $_this->getParam('hard_limit')) { 110 App::logMsg(sprintf('Serialized variable (%s bytes) more than hard_limit (%s bytes).', $serialized_var_len, $_this->getParam('hard_limit')), LOG_NOTICE, __FILE__, __LINE__); 117 111 return false; 118 112 } … … 123 117 unset($_SESSION['_session_cache'][$var_id]); 124 118 // 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. 125 while (strlen(serialize($_SESSION['_session_cache'])) + $serialized_var_len >= $ this->getParam('soft_limit')126 && sizeof($_SESSION['_session_cache']) >= $ this->getParam('min_items')) {119 while (strlen(serialize($_SESSION['_session_cache'])) + $serialized_var_len >= $_this->getParam('soft_limit') 120 && sizeof($_SESSION['_session_cache']) >= $_this->getParam('min_items')) { 127 121 array_shift($_SESSION['_session_cache']); 128 122 } … … 149 143 function getCache($var_id) 150 144 { 151 if (!isset($this) || !is_a($this, 'SessionCache') && !is_subclass_of($this, 'SessionCache')) { 152 $this =& SessionCache::getInstance(); 153 } 154 155 if (!$this->getParam('enabled')) { 145 $_this =& SessionCache::getInstance(); 146 147 if (!$_this->getParam('enabled')) { 156 148 return false; 157 149 } … … 179 171 function isCached($var_id) 180 172 { 181 if (!isset($this) || !is_a($this, 'SessionCache') && !is_subclass_of($this, 'SessionCache')) { 182 $this =& SessionCache::getInstance(); 183 } 184 185 if (!$this->getParam('enabled')) { 173 $_this =& SessionCache::getInstance(); 174 175 if (!$_this->getParam('enabled')) { 186 176 return false; 187 177 }
Note: See TracChangeset
for help on using the changeset viewer.