当前位置: 首页>>代码示例>>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;未经允许,请勿转载。