_host = $config['host']; } if (isset($config['port'])) { $this->_port = $config['port']; } if (isset($config['timeout'])) { $this->_timeout = $config['timeout']; } if (isset($config['prefix'])) { $this->_prefix = $config['prefix']; } $this->_cache = new Memcache(); if (!$this->_cache->connect($this->_host, $this->_port)) { // dont use fatal here since we can go in an infinite loop echo 'Could not connect to Memcached server'; CRM_Utils_System::civiExit(); } } /** * @param $key * @param $value * * @return bool */ function set($key, &$value) { if (!$this->_cache->set($this->_prefix . $key, $value, FALSE, $this->_timeout)) { return FALSE; } return TRUE; } /** * @param $key * * @return mixed */ function &get($key) { $result = $this->_cache->get($this->_prefix . $key); return $result; } /** * @param $key * * @return mixed */ function delete($key) { return $this->_cache->delete($this->_prefix . $key); } /** * @return mixed */ function flush() { return $this->_cache->flush(); } }