Use of Redis Subscribe in PHP

Source: Internet
Author: User
Ladies and gentlemen, the great gods.

There has been a recent subscription and distribution of Redis Subscribe,publish.

1.php

function f ($redis, $chan, $msg) {      switch ($chan) {case          ' chan-1 ':              echo 1;            echo $msg;            break;          Case ' chan-2 ':              Echo 2;            echo $msg;            break;         Case ' chan-3 ':            echo 3;          echo $msg;            break;      }  }    


2.php
$redis->publish (' chan-1 ', ' Hello Word ');


My question is: I subscribed to 3 Chan in 1.php and then publish data to Chan-1 in 2.php.
Then the browser opens 1.php has been in the loop. and then to timeout.

My question is: how do I see the output data in 1.php?


Reply to discussion (solution)

Excuse me, is this problem solved upstairs?

The subscribe is blocking mode and will never end. You can see what's printed on the command line by executing your first script.

  • Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.