/**
  * Return memcached connection object
  *
  * @return  object   memcached connection object
  *
  * @since   12.1
  */
 protected function getConnection()
 {
     if ((extension_loaded('memcached') && class_exists('Memcached')) != true) {
         return false;
     }
     $config = JFactory::getConfig();
     $this->_persistent = $config->get('memcache_persist', true);
     $this->_compress = $config->get('memcache_compress', false) == false ? 0 : Memcached::OPT_COMPRESSION;
     /*
      * This will be an array of loveliness
      * @todo: multiple servers
      * $servers	= (isset($params['servers'])) ? $params['servers'] : array();
      */
     $server = array();
     $server['host'] = $config->get('memcache_server_host', 'localhost');
     $server['port'] = $config->get('memcache_server_port', 11211);
     // Create the memcache connection
     if ($this->_persistent) {
         $session = JFactory::getSession();
         self::$_db = new Memcached($session->getId());
     } else {
         self::$_db = new Memcached();
     }
     $memcachedtest = self::$_db->addServer($server['host'], $server['port']);
     if ($memcachedtest == false) {
         return JError::raiseError(404, "Could not connect to memcached server");
     }
     self::$_db->setOption(Memcached::OPT_COMPRESSION, $this->_compress);
     // Memcached has no list keys, we do our own accounting, initialise key index
     if (self::$_db->get($this->_hash . '-index') === false) {
         $empty = array();
         self::$_db->set($this->_hash . '-index', $empty, 0);
     }
     return;
 }
 /**
  * Sets up the fixture, for example, opens a network connection.
  * This method is called before a test is executed.
  *
  * @return  void
  */
 protected function setUp()
 {
     if (!JCacheStorageMemcached::isSupported() || $this->isBlacklisted('memcached')) {
         $this->markTestSkipped('The Memcached cache handler is not supported on this system.');
     }
     parent::setUp();
     $this->handler = new JCacheStorageMemcached();
     // Override the lifetime because the JCacheStorage API multiplies it by 60 (converts minutes to seconds)
     $this->handler->_lifetime = 2;
 }
 /**
  * Sets up the fixture, for example, opens a network connection.
  * This method is called before a test is executed.
  *
  * @return  void
  */
 protected function setUp()
 {
     if (!JCacheStorageMemcached::isSupported()) {
         $this->markTestSkipped('The Memcached cache handler is not supported on this system.');
     }
     parent::setUp();
     try {
         $this->handler = new JCacheStorageMemcached();
     } catch (JCacheExceptionConnecting $e) {
         $this->markTestSkipped('Failed to connect to Memcached');
     }
     // Override the lifetime because the JCacheStorage API multiplies it by 60 (converts minutes to seconds)
     $this->handler->_lifetime = 2;
 }
 /**
  * Check availability of all cache handlers
  *
  * @return void
  */
 private function checkAvailability()
 {
     $this->available = array('apc' => JCacheStorageApc::isSupported(), 'apcu' => JCacheStorageApcu::isSupported(), 'cachelite' => JCacheStorageCachelite::isSupported(), 'file' => true, 'memcache' => JCacheStorageMemcache::isSupported(), 'memcached' => JCacheStorageMemcached::isSupported(), 'redis' => JCacheStorageRedis::isSupported(), 'wincache' => JCacheStorageWincache::isSupported(), 'xcache' => JCacheStorageXcache::isSupported());
 }
 /**
  * Testing isSupported().
  *
  * @return  void
  */
 public function testIsSupported()
 {
     $this->assertEquals($this->extensionAvailable, $this->object->isSupported(), 'Claims Memcache is not loaded.');
 }