disconnect() 공개 메소드

Closes the underlying connection and disconnects from the server.
public disconnect ( )
예제 #1
1
파일: Clear.php 프로젝트: eveseat/console
 /**
  * Flush all keys in Redis
  */
 public function clear_redis_cache()
 {
     $redis_host = config('database.redis.default.host');
     $redis_port = config('database.redis.default.port');
     $this->info('Clearing the Redis Cache at: ' . $redis_host . ':' . $redis_port);
     try {
         $redis = new Client(['host' => $redis_host, 'port' => $redis_port]);
         $redis->flushall();
         $redis->disconnect();
     } catch (Exception $e) {
         $this->error('Failed to clear the Redis Cache. Error: ' . $e->getMessage());
     }
     return;
 }
예제 #2
0
 /**
  * @inheritdoc
  */
 public function disconnect()
 {
     if (!$this->isConnected()) {
         return;
     }
     $this->client->disconnect();
     $this->client = null;
 }
 public function fork()
 {
     $id = pcntl_fork();
     if (!$id) {
         $this->redis->disconnect();
         $this->redis->connect();
     }
     return $id;
 }
예제 #4
0
파일: Predis.php 프로젝트: sergeym/Stash
 /**
  * Properly close the connection.
  *
  * {@inheritdoc}
  */
 public function __destruct()
 {
     if ($this->redis instanceof \Predis\Client) {
         try {
             $this->redis->disconnect();
         } catch (\ConnectionException $e) {
             /*
              * \Predis\Client::disconnect will throw a \ConnectionException("Redis server went away") exception if
              * we haven't previously been able to connect to Redis or the connection has severed.
              */
         }
     }
 }
예제 #5
0
 public function Cleanup()
 {
     $this->status = 'offline';
     $this->Report();
     $this->redis->disconnect();
     unset($this->beanstalk);
     unset($this->redis);
 }
예제 #6
0
 public static function setUpBeforeClass()
 {
     parent::setUpBeforeClass();
     $client = new Client();
     try {
         $client->connect();
         $client->disconnect();
         self::$supported = true;
     } catch (ConnectionException $e) {
         self::$supported = false;
     }
 }
예제 #7
0
 /**
  * @group disconnected
  */
 public function testConnectAndDisconnect()
 {
     $connection = $this->getMock('Predis\\Connection\\ConnectionInterface');
     $connection->expects($this->once())->method('connect');
     $connection->expects($this->once())->method('disconnect');
     $client = new Client($connection);
     $client->connect();
     $client->disconnect();
 }
예제 #8
0
파일: Predis.php 프로젝트: jeffery/Cache
 public function __destruct()
 {
     $this->predis->disconnect();
 }
예제 #9
0
 /**
  * @group connected
  * @requires extension pcntl
  */
 public function testPubSubAgainstRedisServerBlocking()
 {
     $parameters = array('host' => REDIS_SERVER_HOST, 'port' => REDIS_SERVER_PORT, 'database' => REDIS_SERVER_DBNUM, 'read_write_timeout' => -1);
     $options = array('profile' => REDIS_SERVER_VERSION);
     // create consumer before forking so the child can disconnect it
     $consumer = new Client($parameters, $options);
     $consumer->connect();
     /*
      * fork
      *  parent: consumer
      *  child: producer
      */
     if ($childPID = pcntl_fork()) {
         $messages = array();
         $pubsub = new PubSubConsumer($consumer);
         $pubsub->subscribe('channel:foo');
         foreach ($pubsub as $message) {
             if ($message->kind !== 'message') {
                 continue;
             }
             $messages[] = $payload = $message->payload;
             if ($payload === 'QUIT') {
                 $pubsub->stop();
             }
         }
         $this->assertSame(array('message1', 'message2', 'QUIT'), $messages);
         $this->assertFalse($pubsub->valid());
         $this->assertEquals('ECHO', $consumer->echo('ECHO'));
         // kill the child
         posix_kill($childPID, SIGKILL);
     } else {
         // create producer, read_write_timeout = 2 because it doesn't do blocking reads anyway
         $producer = new Client(array_replace($parameters, array('read_write_timeout' => 2)), $options);
         $producer->connect();
         $producer->publish('channel:foo', 'message1');
         $producer->publish('channel:foo', 'message2');
         $producer->publish('channel:foo', 'QUIT');
         // sleep, giving the consumer a chance to respond to the QUIT message
         sleep(1);
         // disconnect the consumer because otherwise it could remain stuck in blocking read
         //  if it failed to respond to the QUIT message
         $consumer->disconnect();
         // exit child
         exit(0);
     }
 }
예제 #10
0
파일: Client.php 프로젝트: Antevenio/redis
 public function disconnect()
 {
     $this->_client->disconnect();
 }
예제 #11
0
파일: Redis.php 프로젝트: alambike/phpback
 public function __destruct()
 {
     $this->client->disconnect();
 }