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