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);
}