| | |
| | | array($this, 'mc_read'), |
| | | array($this, 'mc_write'), |
| | | array($this, 'mc_destroy'), |
| | | array($this, 'rcube_gc')); |
| | | array($this, 'gc')); |
| | | } |
| | | else { |
| | | raise_error(array('code' => 604, 'type' => 'db', |
| | |
| | | $now = $this->db->fromunixtime((int)$ts); |
| | | |
| | | // use internal data from read() for fast requests (up to 0.5 sec.) |
| | | if ($key == $this->key && $ts - $this->start < 0.5) { |
| | | if ($key == $this->key && (!$this->vars || $ts - $this->start < 0.5)) { |
| | | $oldvars = $this->vars; |
| | | } else { // else read data again from DB |
| | | $oldvars = $this->read($key); |
| | | $oldvars = $this->db_read($key); |
| | | } |
| | | |
| | | if ($oldvars !== false) { |
| | | $newvars = $this->_fixvars($vars, $oldvars); |
| | | |
| | | |
| | | if ($newvars !== $oldvars) { |
| | | $this->db->query( |
| | | sprintf("UPDATE %s SET vars=?, changed=%s WHERE sess_id=?", |
| | |
| | | $key, base64_encode($vars), (string)$this->ip); |
| | | } |
| | | |
| | | $this->unsets = array(); |
| | | return true; |
| | | } |
| | | |
| | | |
| | | |
| | | |
| | | /** |
| | | * Merge vars with old vars and apply unsets |
| | | */ |
| | | private function _fixvars($vars, $oldvars) |
| | | { |
| | | $ts = microtime(true); |
| | |
| | | else |
| | | $newvars = $vars; |
| | | } |
| | | |
| | | |
| | | $this->unsets = array(); |
| | | return $newvars; |
| | | } |
| | |
| | | sprintf("DELETE FROM %s WHERE changed < %s", |
| | | get_table_name('session'), $this->db->fromunixtime(time() - $maxlifetime))); |
| | | |
| | | $this->rcube_gc(); |
| | | $this->gc(); |
| | | |
| | | return true; |
| | | } |
| | |
| | | $ts = microtime(true); |
| | | |
| | | // use internal data for fast requests (up to 0.5 sec.) |
| | | if ($key == $this->key && $ts - $this->start < 0.5) |
| | | if ($key == $this->key && (!$this->vars || $ts - $this->start < 0.5)) |
| | | $oldvars = $this->vars; |
| | | else // else read data again |
| | | $oldvars = $this->mc_read($key); |
| | |
| | | /** |
| | | * Execute registered garbage collector routines |
| | | */ |
| | | public function rcube_gc() |
| | | public function gc() |
| | | { |
| | | foreach ($this->gc_handlers as $fct) |
| | | $fct(); |