當前位置: 首頁>>代碼示例>>PHP>>正文


PHP Client::disconnect方法代碼示例

本文整理匯總了PHP中Predis\Client::disconnect方法的典型用法代碼示例。如果您正苦於以下問題:PHP Client::disconnect方法的具體用法?PHP Client::disconnect怎麽用?PHP Client::disconnect使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在Predis\Client的用法示例。


在下文中一共展示了Client::disconnect方法的11個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: clear_redis_cache

 /**
  * 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;
 }
開發者ID:eveseat,項目名稱:console,代碼行數:17,代碼來源:Clear.php

示例2: disconnect

 /**
  * @inheritdoc
  */
 public function disconnect()
 {
     if (!$this->isConnected()) {
         return;
     }
     $this->client->disconnect();
     $this->client = null;
 }
開發者ID:tonicospinelli,項目名稱:disque-php,代碼行數:11,代碼來源:Predis.php

示例3: fork

 public function fork()
 {
     $id = pcntl_fork();
     if (!$id) {
         $this->redis->disconnect();
         $this->redis->connect();
     }
     return $id;
 }
開發者ID:halaei,項目名稱:redis-hyper-queue,代碼行數:9,代碼來源:IntegrationTestCase.php

示例4: __destruct

 /**
  * 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.
              */
         }
     }
 }
開發者ID:sergeym,項目名稱:Stash,代碼行數:18,代碼來源:Predis.php

示例5: Cleanup

 public function Cleanup()
 {
     $this->status = 'offline';
     $this->Report();
     $this->redis->disconnect();
     unset($this->beanstalk);
     unset($this->redis);
 }
開發者ID:Grosloup,項目名稱:PHP-Workers-Tutorial,代碼行數:8,代碼來源:worker.php

示例6: setUpBeforeClass

 public static function setUpBeforeClass()
 {
     parent::setUpBeforeClass();
     $client = new Client();
     try {
         $client->connect();
         $client->disconnect();
         self::$supported = true;
     } catch (ConnectionException $e) {
         self::$supported = false;
     }
 }
開發者ID:kormik,項目名稱:manager,代碼行數:12,代碼來源:PredisStoreGeneratorTest.php

示例7: testConnectAndDisconnect

 /**
  * @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();
 }
開發者ID:rodrigopbel,項目名稱:ong,代碼行數:12,代碼來源:ClientTest.php

示例8: __destruct

 public function __destruct()
 {
     $this->predis->disconnect();
 }
開發者ID:jeffery,項目名稱:Cache,代碼行數:4,代碼來源:Predis.php

示例9: testPubSubAgainstRedisServerBlocking

 /**
  * @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);
     }
 }
開發者ID:pikniktech,項目名稱:dailybriefweb2,代碼行數:50,代碼來源:ConsumerTest.php

示例10: disconnect

 public function disconnect()
 {
     $this->_client->disconnect();
 }
開發者ID:Antevenio,項目名稱:redis,代碼行數:4,代碼來源:Client.php

示例11: __destruct

 public function __destruct()
 {
     $this->client->disconnect();
 }
開發者ID:alambike,項目名稱:phpback,代碼行數:4,代碼來源:Redis.php


注:本文中的Predis\Client::disconnect方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。