public function getMemcached()
 {
     try {
         $m = new \Memcached();
         $m->addServer(self::HOST, self::PORT);
         $stats = $m->getStats();
         $host = self::HOST . ':' . self::PORT;
         if ($stats[$host]['pid'] == -1) {
             throw new \Exception(sprintf('Unable to reach a memcached server on %s', $host));
         }
     } catch (\Exception $e) {
         $this->markTestSkipped($e->getMessage());
     }
     return $m;
 }
Exemplo n.º 2
6
 /**
  * Returns the indexed items.
  *
  * @return boolean Returns True on success or Null on failure.
  */
 public function load()
 {
     // &$cas_token holds the unique 64-bit float token generated
     // by memcache for the named item @see \Memcached::get
     $str = $this->engine->get($this->name, $cas_token);
     if (null === $str) {
         return null;
     }
     $this->items = $this->serializer->unserialize($str);
     if ($this->serializer->getDirtiness() > self::DIRTINESS_THRESHOLD) {
         $this->purge($cas_token);
     }
     return $this->items;
 }