/** */ public function get($key, $lifetime = 0) { $original_key = $key; $key = $this->_params['prefix'] . $key; if (isset($this->_expirecache[$key])) { return $this->_expirecache[$key]; } $key_list = array($key); if (!empty($lifetime)) { $key_list[] = $key . '_e'; } $res = $this->_memcache->get($key_list); if ($res === false) { unset($this->_expirecache[$key]); } else { // If we can't find the expire time, assume we have exceeded it. if (empty($lifetime) || $res[$key . '_e'] !== false && $res[$key . '_e'] + $lifetime > time()) { $this->_expirecache[$key] = $res[$key]; } else { $res[$key] = false; $this->expire($original_key); } } return $res[$key]; }
/** * Do garbage collection for session tracking information. */ public function trackGC() { $this->_memcache->lock($this->_trackID); $ids = $this->_memcache->get($this->_trackID); if (empty($ids)) { $this->_memcache->unlock($this->_trackID); return; } $tstamp = time() - $this->_params['track_lifetime']; $alter = false; foreach ($ids as $key => $val) { if ($tstamp > $val) { unset($ids[$key]); $alter = true; } } if ($alter) { $this->_memcache->set($this->_trackID, $ids); } $this->_memcache->unlock($this->_trackID); }
/** */ protected function _get($keys) { return ($res = $this->_memcache->get($keys)) === false ? array_fill_keys($keys, false) : $res; }