当前位置: 首页>>代码示例>>PHP>>正文


PHP Pool::subscribe方法代码示例

本文整理汇总了PHP中Pool::subscribe方法的典型用法代码示例。如果您正苦于以下问题:PHP Pool::subscribe方法的具体用法?PHP Pool::subscribe怎么用?PHP Pool::subscribe使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Pool的用法示例。


在下文中一共展示了Pool::subscribe方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: onReady

 /**
  * Called when the worker is ready to go.
  * @return void
  */
 public function onReady()
 {
     $this->redis = \PHPDaemon\Clients\Redis\Pool::getInstance();
     /*$this->redis->eval("return {'a','b','c', {'d','e','f', {'g','h','i'}} }",0, function($redis) {
     			Daemon::log(Debug::dump($redis->result));
     		});*/
     $this->redis->subscribe('te3st', function ($redis) {
         Daemon::log(Debug::dump($redis->result));
     });
     $this->redis->psubscribe('test*', function ($redis) {
         Daemon::log(Debug::dump($redis->result));
     });
 }
开发者ID:cobolbaby,项目名称:phpdaemon,代码行数:17,代码来源:Simple.php

示例2: onReady

 /**
  * Called when the worker is ready to go
  * @return void
  */
 public function onReady()
 {
     $this->redis = \PHPDaemon\Clients\Redis\Pool::getInstance();
     $this->redis->hmset('myset', 'field1', 'value1', 'field2', 'value2', 'field3', 'value3', 'field4', 'value4', 'field5', 'value5', function ($redis) {
         $this->redis->hgetall('myset', function ($redis) {
             D('TEST 1: HGETALL');
             foreach ($redis as $key => $value) {
                 D($key . ' - ' . $value);
             }
             D($redis->assoc);
         });
         $this->redis->hmget('myset', 'field2', 'field4', function ($redis) {
             D('TEST 2: HMGET');
             foreach ($redis as $key => $value) {
                 D($key . ' - ' . $value);
             }
             D($redis->assoc);
         });
     });
     $this->redis->zadd('myzset', 100, 'one', 150, 'two', 325, 'three', function ($redis) {
         $this->redis->zrange('myzset', 0, -1, function ($redis) {
             D('TEST 3: ZRANGE');
             foreach ($redis as $key => $value) {
                 D($key . ' - ' . $value);
             }
             D($redis->assoc);
         });
         $this->redis->zrange('myzset', 0, -1, 'WITHSCORES', function ($redis) {
             D('TEST 4: ZRANGE WITHSCORES');
             foreach ($redis as $key => $value) {
                 D($key . ' - ' . $value);
             }
             D($redis->assoc);
         });
     });
     $this->redis->subscribe('mysub', function ($redis) {
         D('TEST 5: SUB & PUB');
         foreach ($redis as $key => $value) {
             D($key . ' - ' . $value);
         }
         D($redis->channel, $redis->msg, $redis->assoc);
     });
     $this->redis->publish('mysub', 'Test message!');
 }
开发者ID:kakserpom,项目名称:phpdaemon,代码行数:48,代码来源:Iterator.php


注:本文中的Pool::subscribe方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。