| @@ 187-225 (lines=39) @@ | ||
| 184 | * @param string $session_data Serialized session data |
|
| 185 | * @return bool |
|
| 186 | */ |
|
| 187 | public function write($session_id, $session_data) |
|
| 188 | { |
|
| 189 | if ( ! isset($this->_memcached)) |
|
| 190 | { |
|
| 191 | return $this->_failure; |
|
| 192 | } |
|
| 193 | // Was the ID regenerated? |
|
| 194 | elseif ($session_id !== $this->_session_id) |
|
| 195 | { |
|
| 196 | if ( ! $this->_release_lock() OR ! $this->_get_lock($session_id)) |
|
| 197 | { |
|
| 198 | return $this->_failure; |
|
| 199 | } |
|
| 200 | ||
| 201 | $this->_fingerprint = md5(''); |
|
| 202 | $this->_session_id = $session_id; |
|
| 203 | } |
|
| 204 | ||
| 205 | if (isset($this->_lock_key)) |
|
| 206 | { |
|
| 207 | $this->_memcached->replace($this->_lock_key, time(), 300); |
|
| 208 | if ($this->_fingerprint !== ($fingerprint = md5($session_data))) |
|
| 209 | { |
|
| 210 | if ($this->_memcached->set($this->_key_prefix.$session_id, $session_data, $this->_config['expiration'])) |
|
| 211 | { |
|
| 212 | $this->_fingerprint = $fingerprint; |
|
| 213 | return $this->_success; |
|
| 214 | } |
|
| 215 | ||
| 216 | return $this->_failure; |
|
| 217 | } |
|
| 218 | ||
| 219 | return $this->_memcached->touch($this->_key_prefix.$session_id, $this->_config['expiration']) |
|
| 220 | ? $this->_success |
|
| 221 | : $this->_failure; |
|
| 222 | } |
|
| 223 | ||
| 224 | return $this->_failure; |
|
| 225 | } |
|
| 226 | ||
| 227 | // ------------------------------------------------------------------------ |
|
| 228 | ||
| @@ 188-226 (lines=39) @@ | ||
| 185 | * @param string $session_data Serialized session data |
|
| 186 | * @return bool |
|
| 187 | */ |
|
| 188 | public function write($session_id, $session_data) |
|
| 189 | { |
|
| 190 | if ( ! isset($this->_redis)) |
|
| 191 | { |
|
| 192 | return $this->_failure; |
|
| 193 | } |
|
| 194 | // Was the ID regenerated? |
|
| 195 | elseif ($session_id !== $this->_session_id) |
|
| 196 | { |
|
| 197 | if ( ! $this->_release_lock() OR ! $this->_get_lock($session_id)) |
|
| 198 | { |
|
| 199 | return $this->_failure; |
|
| 200 | } |
|
| 201 | ||
| 202 | $this->_fingerprint = md5(''); |
|
| 203 | $this->_session_id = $session_id; |
|
| 204 | } |
|
| 205 | ||
| 206 | if (isset($this->_lock_key)) |
|
| 207 | { |
|
| 208 | $this->_redis->setTimeout($this->_lock_key, 300); |
|
| 209 | if ($this->_fingerprint !== ($fingerprint = md5($session_data))) |
|
| 210 | { |
|
| 211 | if ($this->_redis->set($this->_key_prefix.$session_id, $session_data, $this->_config['expiration'])) |
|
| 212 | { |
|
| 213 | $this->_fingerprint = $fingerprint; |
|
| 214 | return $this->_success; |
|
| 215 | } |
|
| 216 | ||
| 217 | return $this->_failure; |
|
| 218 | } |
|
| 219 | ||
| 220 | return ($this->_redis->setTimeout($this->_key_prefix.$session_id, $this->_config['expiration'])) |
|
| 221 | ? $this->_success |
|
| 222 | : $this->_failure; |
|
| 223 | } |
|
| 224 | ||
| 225 | return $this->_failure; |
|
| 226 | } |
|
| 227 | ||
| 228 | // ------------------------------------------------------------------------ |
|
| 229 | ||