コード例 #1
0
ファイル: Redis.php プロジェクト: comelyio/comely
 /**
  * Revive existing connection or establish a new one
  */
 public function connect()
 {
     // Check if already connected
     if (!$this->isConnected()) {
         // Establish connection
         $errorNum = 0;
         $errorMsg = "";
         $redis = @stream_socket_client(sprintf('%s:%d', $this->host, $this->port), $errorNum, $errorMsg, $this->cache->getTimeout());
         // Do we have stream (resource) ?
         if (!$redis) {
             throw EngineException::connectionError(__CLASS__, sprintf('Redis connection error[%1$d]: %2$s', $errorNum, $errorMsg));
         } else {
             $this->socket = $redis;
             @stream_set_timeout($this->socket, $this->cache->getTimeout());
         }
     }
 }