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


PHP Client::echo方法代碼示例

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


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

示例1: debugLog

 /**
  * Create a debug log
  *
  * @param string $msg
  *
  * @return void
  */
 public function debugLog($msg)
 {
     if (!$this->getDebugMode() || !$msg) {
         return;
     }
     if ($msg[0] == '@') {
         $this->unit_of_work->addCommand('ConnectionEcho', [substr($msg, 1)]);
     } else {
         $this->client->echo($msg);
     }
 }
開發者ID:andreyors,項目名稱:orm,代碼行數:18,代碼來源:RedisDriver.php

示例2: testMonitorAgainstRedisServer

 /**
  * @group connected
  */
 public function testMonitorAgainstRedisServer()
 {
     $parameters = array('host' => REDIS_SERVER_HOST, 'port' => REDIS_SERVER_PORT, 'database' => REDIS_SERVER_DBNUM, 'read_write_timeout' => 2);
     $options = array('profile' => REDIS_SERVER_VERSION);
     $echoed = array();
     $producer = new Client($parameters, $options);
     $producer->connect();
     $consumer = new Client($parameters, $options);
     $consumer->connect();
     $monitor = new MonitorContext($consumer);
     $producer->echo('message1');
     $producer->echo('message2');
     $producer->echo('QUIT');
     foreach ($monitor as $message) {
         if ($message->command == 'ECHO') {
             $echoed[] = $arguments = trim($message->arguments, '"');
             if ($arguments == 'QUIT') {
                 $monitor->closeContext();
             }
         }
     }
     $this->assertSame(array('message1', 'message2', 'QUIT'), $echoed);
     $this->assertFalse($monitor->valid());
     $this->assertTrue($consumer->ping());
 }
開發者ID:kchhainarong,項目名稱:chantuchP,代碼行數:28,代碼來源:MonitorContextTest.php

示例3: 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

示例4: testPubSubAgainstRedisServer

 /**
  * @group connected
  */
 public function testPubSubAgainstRedisServer()
 {
     $parameters = array('host' => REDIS_SERVER_HOST, 'port' => REDIS_SERVER_PORT, 'database' => REDIS_SERVER_DBNUM, 'read_write_timeout' => 2);
     $options = array('profile' => REDIS_SERVER_VERSION);
     $messages = array();
     $producer = new Client($parameters, $options);
     $producer->connect();
     $consumer = new Client($parameters, $options);
     $consumer->connect();
     $pubsub = new PubSubContext($consumer);
     $pubsub->subscribe('channel:foo');
     $producer->publish('channel:foo', 'message1');
     $producer->publish('channel:foo', 'message2');
     $producer->publish('channel:foo', 'QUIT');
     foreach ($pubsub as $message) {
         if ($message->kind !== 'message') {
             continue;
         }
         $messages[] = $payload = $message->payload;
         if ($payload === 'QUIT') {
             $pubsub->closeContext();
         }
     }
     $this->assertSame(array('message1', 'message2', 'QUIT'), $messages);
     $this->assertFalse($pubsub->valid());
     $this->assertEquals('ECHO', $consumer->echo('ECHO'));
 }
開發者ID:kchhainarong,項目名稱:chantuchP,代碼行數:30,代碼來源:PubSubContextTest.php


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