Prado\Caching\TMemCache::init PHP Method

init() public method

This method is required by the IModule interface. It makes sure that UniquePrefix has been set, creates a Memcache instance and connects to the memcache server.
public init ( $config )
    public function init($config)
    {
        if (!extension_loaded('memcache') && !$this->_useMemcached) {
            throw new TConfigurationException('memcache_extension_required');
        }
        if (!extension_loaded('memcached') && $this->_useMemcached) {
            throw new TConfigurationException('memcached_extension_required');
        }
        $this->_cache = $this->_useMemcached ? new Memcached() : new Memcache();
        $this->loadConfig($config);
        if (count($this->_servers)) {
            foreach ($this->_servers as $server) {
                Prado::trace('Adding server ' . $server['Host'] . ' from serverlist', '\\Prado\\Caching\\TMemCache');
                if ($this->_cache->addServer($server['Host'], $server['Port'], $server['Persistent'], $server['Weight'], $server['Timeout'], $server['RetryInterval']) === false) {
                    throw new TConfigurationException('memcache_connection_failed', $server['Host'], $server['Port']);
                }
            }
        } else {
            Prado::trace('Adding server ' . $this->_host, '\\Prado\\Caching\\TMemCache');
            if ($this->_cache->addServer($this->_host, $this->_port) === false) {
                throw new TConfigurationException('memcache_connection_failed', $this->_host, $this->_port);
            }
        }
        if ($this->_threshold !== 0) {
            $this->_cache->setCompressThreshold($this->_threshold, $this->_minSavings);
        }
        $this->_initialized = true;
        parent::init($config);
    }