Changeset 154 for trunk/lib/Cache.inc.php
- Timestamp:
- Jun 8, 2006 5:36:10 AM (18 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/lib/Cache.inc.php
r153 r154 47 47 function Cache($namespace='') 48 48 { 49 $this->_ns = '_cache' .$namespace;50 51 if (!isset($_SESSION[ $this->_ns])) {49 $this->_ns = $namespace; 50 51 if (!isset($_SESSION['_cache'][$this->_ns])) { 52 52 $this->clear(); 53 53 } … … 146 146 147 147 // Remove any value already stored under this key. 148 unset($_SESSION[ $this->_ns][$keyhash]);148 unset($_SESSION['_cache'][$this->_ns][$keyhash]); 149 149 150 150 // Continue to prune the cache if its size is greater than stack_size_limit, but keep at least min_items. 151 while (strlen(serialize($_SESSION[ $this->_ns])) + $var_len >= $this->getParam('stack_size_limit') && sizeof($_SESSION[$this->_ns]) >= $this->getParam('min_items')) {152 array_shift($_SESSION[ $this->_ns]);151 while (strlen(serialize($_SESSION['_cache'][$this->_ns])) + $var_len >= $this->getParam('stack_size_limit') && sizeof($_SESSION['_cache'][$this->_ns]) >= $this->getParam('min_items')) { 152 array_shift($_SESSION['_cache'][$this->_ns]); 153 153 } 154 154 155 155 // Save this value under the specified key. 156 $_SESSION[ $this->_ns][$keyhash] =& $var;156 $_SESSION['_cache'][$this->_ns][$keyhash] =& $var; 157 157 158 158 if ($var_len >= 1024000) { … … 182 182 183 183 $keyhash = md5($key); 184 if (isset($_SESSION[ $this->_ns][$keyhash])) {184 if (isset($_SESSION['_cache'][$this->_ns][$keyhash])) { 185 185 $app->logMsg(sprintf('Retreiving %s from cache.', $key), LOG_DEBUG, __FILE__, __LINE__); 186 186 // Move the accessed cached datum to the top of the stack. Maybe somebody knows a better way to do this? 187 $tmp =& $_SESSION[ $this->_ns][$keyhash];188 unset($_SESSION[ $this->_ns][$keyhash]);189 $_SESSION[ $this->_ns][$keyhash] =& $tmp;187 $tmp =& $_SESSION['_cache'][$this->_ns][$keyhash]; 188 unset($_SESSION['_cache'][$this->_ns][$keyhash]); 189 $_SESSION['_cache'][$this->_ns][$keyhash] =& $tmp; 190 190 // Return the unserialized datum. 191 return unserialize($_SESSION[ $this->_ns][$keyhash]);191 return unserialize($_SESSION['_cache'][$this->_ns][$keyhash]); 192 192 } else { 193 193 return false; … … 208 208 209 209 $keyhash = md5($key); 210 return array_key_exists($keyhash, $_SESSION[ $this->_ns]);210 return array_key_exists($keyhash, $_SESSION['_cache'][$this->_ns]); 211 211 } 212 212 … … 220 220 { 221 221 $keyhash = md5($key); 222 unset($_SESSION[ $this->_ns][$keyhash]);222 unset($_SESSION['_cache'][$this->_ns][$keyhash]); 223 223 } 224 224 … … 233 233 function clear() 234 234 { 235 $_SESSION[ $this->_ns] = array();235 $_SESSION['_cache'][$this->_ns] = array(); 236 236 } 237 237
Note: See TracChangeset
for help on using the changeset viewer.