protected function getConnection()
    {
        if (empty($this->memcache)) {

            //ini_set('memcache.chunk_size', 32768);
            //ini_set('memcache.allow_failover', false); // default is usually true
            //ini_set('memcache.hash_strategy', 'consistent');

            $this->memcache = new Memcache;

            // Add the servers
            if (!is_array($this->memcachedServers) || count($this->memcachedServers) < 1)
                throw new CacheException('At least one server must be specified.');

            foreach ( $this->memcachedServers as $server ) {
                $options = array_merge(array('port'             => 11211,
                                             'persistent'       => true,
                                             'weight'           => 1,
                                             'timeout'          => 1,
                                             'retry_interval'   => 15,
                                             'status'           => true,
                                             'failure_callback' => null), array_change_key_case($server, CASE_LOWER));

                $this->Logger->debug("Adding memcached server:\n");
                $this->Logger->debug($options);

//                if(!array_key_exists('failure_callback', $options))
//                    $options['failure_callback'] = array(__CLASS__, '_failureCallback');

                if ($this->memcache->addServer($options['host'], $options['port'],
                                            $options['persistent'], $options['weight'],
                                            $options['timeout'], $options['retry_interval'],
                                            $options['status'], $options['failure_callback']) === false) {
                    throw new CacheException("Unable to add memcache server: {$options['host']}");
                }
            }
        }

        return $this->memcache;
    }
protected function getConnection()
    {
        if (empty($this->memcache)) {

            //ini_set('memcache.chunk_size', 32768);
            //ini_set('memcache.allow_failover', false); // default is usually true
            //ini_set('memcache.hash_strategy', 'consistent');

            $this->memcache = new Memcache;

            // Add the servers
            if (!is_array($this->memcachedServers) || count($this->memcachedServers) < 1)
                throw new CacheException('At least one server must be specified.');

            foreach ( $this->memcachedServers as $server ) {
                $options = array_merge(array('port'             => 11211,
                                             'persistent'       => true,
                                             'weight'           => 1,
                                             'timeout'          => 1,
                                             'retry_interval'   => 15,
                                             'status'           => true,
                                             'failure_callback' => null), array_change_key_case($server, CASE_LOWER));

                $this->Logger->debug("Adding memcached server:\n");
                $this->Logger->debug($options);

//                if(!array_key_exists('failure_callback', $options))
//                    $options['failure_callback'] = array(__CLASS__, '_failureCallback');

                if ($this->memcache->addServer($options['host'], $options['port'],
                                            $options['persistent'], $options['weight'],
                                            $options['timeout'], $options['retry_interval'],
                                            $options['status'], $options['failure_callback']) === false) {
                    throw new CacheException("Unable to add memcache server: {$options['host']}");
                }
            }
        }

        return $this->memcache;
    }
protected function getConnection ( ) { if ( empty ( $ this -> memcache ) ) { //ini_set('memcache.chunk_size', 32768); //ini_set('memcache.allow_failover', false); // default is usually true //ini_set('memcache.hash_strategy', 'consistent'); $ this -> memcache = new Memcache ; // Add the servers if ( ! is_array ( $ this -> memcachedServers ) || count ( $ this -> memcachedServers ) < 1 ) throw new CacheException ( 'At least one server must be specified.' ) ; foreach ( $ this -> memcachedServers as $ server ) { $ options = array_merge ( array ( 'port' => 11211 , 'persistent' => true , 'weight' => 1 , 'timeout' => 1 , 'retry_interval' => 15 , 'status' => true , 'failure_callback' => null ) , array_change_key_case ( $ server , CASE_LOWER ) ) ; $ this -> Logger -> debug ( "Adding memcached server:\n" ) ; $ this -> Logger -> debug ( $ options ) ; //                if(!array_key_exists('failure_callback', $options)) //                    $options['failure_callback'] = array(__CLASS__, '_failureCallback'); if ( $ this -> memcache -> addServer ( $ options [ 'host' ] , $ options [ 'port' ] , $ options [ 'persistent' ] , $ options [ 'weight' ] , $ options [ 'timeout' ] , $ options [ 'retry_interval' ] , $ options [ 'status' ] , $ options [ 'failure_callback' ] ) === false ) { throw new CacheException ( "Unable to add memcache server: {$options['host']}" ) ; } } } return $ this -> memcache ; }
Returns a connection to the memcached server

@return Memcache an active Memcache object
Returns a connection to the memcached server