// attempt to get status of servers
$stats =
$this->memcached->
getStats();
// $stats should be an associate array with a key in the format of host:port.
// If it doesn't have the key, we know the server is not working as expected.
if (!
isset($stats[$this->config
['host'
] . ':' .
$this->config
['port'
]])) { throw new CriticalError('Cache: Memcached connection failed.'
);
} } elseif (class_exists(Memcache::
class)) { // Create new instance of Memcache
$this->memcached =
new Memcache();
// Check if we can connect to the server
$canConnect =
$this->memcached->
connect( $this->config
['host'
],
$this->config
['port'
] );
// If we can't connect, throw a CriticalError exception
if ($canConnect === false
) { throw new CriticalError('Cache: Memcache connection failed.'
);
}