Ejemplo n.º 1
0
 /**
  * Check if we are still connected to the cache server, reconnect if not.
  *
  * @return bool
  */
 private function ping()
 {
     if (!$this->connected) {
         return false;
     }
     switch (NN_CACHE_TYPE) {
         case self::TYPE_REDIS:
             try {
                 return (bool) $this->server->ping();
             } catch (\RedisException $error) {
                 // nothing to see here, move along
             }
             break;
         case self::TYPE_MEMCACHED:
             $versions = $this->server->getVersion();
             if ($versions) {
                 foreach ($versions as $version) {
                     if ($version != "255.255.255") {
                         return true;
                     }
                 }
             }
             break;
         case self::TYPE_APC:
             return true;
         default:
             return false;
     }
     $this->connect();
     return $this->connected;
 }
Ejemplo n.º 2
0
 /**
  * Redis supports ping'ing the server, so use it.
  */
 private function ping()
 {
     if ($this->isRedis === true) {
         try {
             return (bool) $this->server->ping();
         } catch (\RedisException $error) {
             $this->connect();
             return $this->connected;
         }
     }
     return true;
 }