Changeset 42 for trunk/lib/SessionCache.inc.php
- Timestamp:
- Dec 18, 2005 12:16:03 AM (18 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/lib/SessionCache.inc.php
r41 r42 88 88 * @param str $var_id An identifyer for the cached object. 89 89 * @param bool $force_it_in If we have something really big that we 90 * still want to cache, setting this true 90 * still want to cache, setting this true 91 91 * allows this. 92 92 * … … 106 106 $serialized_var = serialize($var); 107 107 $serialized_var_len = strlen($serialized_var); 108 108 109 109 if ($serialized_var_len >= $this->getParam('soft_limit') && !$force_it_in) { 110 110 App::logMsg(sprintf('Serialized variable (%s bytes) more than soft_limit (%s bytes).', $serialized_var_len, $this->getParam('soft_limit')), LOG_NOTICE, __FILE__, __LINE__); 111 111 return false; 112 112 } 113 113 114 114 if ($serialized_var_len >= $this->getParam('hard_limit')) { 115 115 App::logMsg(sprintf('Serialized variable (%s bytes) more than hard_limit (%s bytes).', $serialized_var_len, $this->getParam('hard_limit')), LOG_NOTICE, __FILE__, __LINE__); … … 122 122 unset($_SESSION['_session_cache'][$var_id]); 123 123 // 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. 124 while (strlen(serialize($_SESSION['_session_cache'])) + $serialized_var_len >= $this->getParam('soft_limit') 124 while (strlen(serialize($_SESSION['_session_cache'])) + $serialized_var_len >= $this->getParam('soft_limit') 125 125 && sizeof($_SESSION['_session_cache']) >= $this->getParam('min_items')) { 126 126 array_shift($_SESSION['_session_cache']); … … 128 128 } 129 129 $_SESSION['_session_cache'][$var_id] =& $serialized_var; 130 130 131 131 if ($serialized_var_len >= 1024000) { 132 132 App::logMsg(sprintf('Successfully cached oversized variable (%s bytes).', $serialized_var_len), LOG_DEBUG, __FILE__, __LINE__); 133 133 } 134 134 135 135 return $var_id; 136 136 } 137 138 /** 139 * Retrives an object from the session cache and returns it unserialized. 137 138 /** 139 * Retrives an object from the session cache and returns it unserialized. 140 140 * It also moves it to the top of the stack, which makes it such that the 141 141 * cache flushing mechanism of putCache deletes the oldest referenced items … … 155 155 return false; 156 156 } 157 157 158 158 $var_id = md5($var_id); 159 159 if (isset($_SESSION['_session_cache'][$var_id])) { … … 168 168 } 169 169 } 170 170 171 171 /** 172 172 * Tells you if the object is cached. … … 189 189 return isset($_SESSION['_session_cache'][$var_id]); 190 190 } 191 191 192 192 /** 193 193 * Tells you if the object is cached.
Note: See TracChangeset
for help on using the changeset viewer.