/** * Initializes the Memcached object & connection. * * @access private * @return void */ private function init() { $this->memcached = new Memcached(md5(MEMCACHED_SERVERS) . $this->reconnectCount++); $this->memcached->setOptions(array(Memcached::OPT_CONNECT_TIMEOUT => MEMCACHED_TIMEOUT, Memcached::OPT_SEND_TIMEOUT => MEMCACHED_TIMEOUT * 1000, Memcached::OPT_RECV_TIMEOUT => MEMCACHED_TIMEOUT * 1000, Memcached::OPT_SERIALIZER => Memcached::HAVE_IGBINARY ? Memcached::SERIALIZER_IGBINARY : (Memcached::HAVE_JSON ? Memcached::SERIALIZER_JSON : Memcached::SERIALIZER_PHP), Memcached::OPT_BINARY_PROTOCOL => true, Memcached::OPT_LIBKETAMA_COMPATIBLE => true, Memcached::OPT_SERVER_FAILURE_LIMIT => 2, Memcached::OPT_AUTO_EJECT_HOSTS => true, Memcached::OPT_PREFIX_KEY => MEMCACHED_PREFIX)); // with persistent connections, only add servers, if they not already added! if (!count($this->memcached->getServerList())) { foreach (explode(',', MEMCACHED_SERVERS) as $host_port) { list($host, $port) = explode(':', trim($host_port)); $this->memcached->addServer($host, $port); } } }