sub.php 401 B

1234567891011121314151617181920
  1. <?php
  2. go(function () {
  3. $redis = new Swoole\Coroutine\Redis();
  4. $redis->connect('127.0.0.1', 6379);
  5. $msg = $redis->subscribe(array("msg_1"));
  6. while ($msg = $redis->recv())
  7. {
  8. var_dump($msg);
  9. }
  10. });
  11. go(function () {
  12. $redis = new Swoole\Coroutine\Redis();
  13. $redis->connect('127.0.0.1', 6379);
  14. $msg = $redis->subscribe(array("msg_2"));
  15. while ($msg = $redis->recv())
  16. {
  17. var_dump($msg);
  18. }
  19. });