Changeset 174 for trunk/lib/Cache.inc.php
- Timestamp:
- Jun 18, 2006 8:50:35 AM (18 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/lib/Cache.inc.php
r172 r174 117 117 118 118 /** 119 * Stores a new variable in the session cache. The $key is is md5'ed 120 * because if a key is numeric, the array_shift function 121 * will reset the key to the next largest int key. Weird behavior I can't 122 * understand. For example $cache["123"] will become $cache[0] 119 * Stores a new variable in the session cache. The $key should not be numberic 120 * because the array_shift function will reset the key to the next largest 121 * int key. Weird behavior I can't understand. For example $cache["123"] will become $cache[0] 123 122 * 124 123 * @param str $key An identifier for the cached object. … … 138 137 } 139 138 140 $keyhash = md5($key);141 139 $var = serialize($var); 142 140 $var_len = strlen($var); … … 153 151 154 152 // Remove any value already stored under this key. 155 unset($_SESSION['_cache'][$this->_ns][$key hash]);153 unset($_SESSION['_cache'][$this->_ns][$key]); 156 154 157 155 // Continue to prune the cache if its size is greater than stack_size_limit, but keep at least min_items. … … 161 159 162 160 // Save this value under the specified key. 163 $_SESSION['_cache'][$this->_ns][$key hash] =& $var;161 $_SESSION['_cache'][$this->_ns][$key] =& $var; 164 162 165 163 if ($var_len >= 1024000) { … … 188 186 } 189 187 190 $keyhash = md5($key); 191 if (isset($_SESSION['_cache'][$this->_ns][$keyhash])) { 188 if (isset($_SESSION['_cache'][$this->_ns][$key])) { 192 189 $app->logMsg(sprintf('Retreiving %s from cache.', $key), LOG_DEBUG, __FILE__, __LINE__); 193 190 // Move the accessed cached datum to the top of the stack. Maybe somebody knows a better way to do this? 194 $tmp =& $_SESSION['_cache'][$this->_ns][$key hash];195 unset($_SESSION['_cache'][$this->_ns][$key hash]);196 $_SESSION['_cache'][$this->_ns][$key hash] =& $tmp;191 $tmp =& $_SESSION['_cache'][$this->_ns][$key]; 192 unset($_SESSION['_cache'][$this->_ns][$key]); 193 $_SESSION['_cache'][$this->_ns][$key] =& $tmp; 197 194 // Return the unserialized datum. 198 return unserialize($_SESSION['_cache'][$this->_ns][$key hash]);195 return unserialize($_SESSION['_cache'][$this->_ns][$key]); 199 196 } else { 200 197 $app->logMsg(sprintf('Missing %s from cache.', $key), LOG_DEBUG, __FILE__, __LINE__); … … 215 212 } 216 213 217 $keyhash = md5($key); 218 return array_key_exists($keyhash, $_SESSION['_cache'][$this->_ns]); 214 return array_key_exists($key, $_SESSION['_cache'][$this->_ns]); 219 215 } 220 216 … … 227 223 function delete($key) 228 224 { 229 $keyhash = md5($key); 230 unset($_SESSION['_cache'][$this->_ns][$keyhash]); 225 unset($_SESSION['_cache'][$this->_ns][$key]); 231 226 } 232 227
Note: See TracChangeset
for help on using the changeset viewer.