redis-pub-publish--sub-Subscription-PHP questions about Redis Subscriptions

Source: Internet
Author: User
Keywords php redis redis-pub-Publish--sub-Subscription
Tags derick pconnect redis version redis server
A.Recently in the study of Redis's Pub/sub (publish subscription feature), use the interface provided by Phpredis to manipulate data.
Current questions:
1. How to set up to solve the timeout limit of Redis subscribe?
Timeout in redis.conf configuration is 0
My Redis version:

Redis server v=3.0.4 sha=00000000:0 malloc=libc bits=64 build=ee774adfcab9032f

My version of PHP:

PHP 5.5.30 (cli) (built: Oct  3 2015 23:46:56) Copyright (c) 1997-2015 The PHP GroupZend Engine v2.5.0, Copyright (c) 1998-2015 Zend Technologies    with Xdebug v2.3.3, Copyright (c) 2002-2015, by Derick Rethans

1.1 Find the answer on the Internet, have said set PHP.ini:

But I did not succeed in this test, the direct report:

redis server went away

1.2 is currently a reference to this link, plus this configuration:

$redis->setOption(Redis::OPT_READ_TIMEOUT, -1);

The local test is always in the connected state.
2. How does the Subscriber ensure that it is running (keep running) to subscribe to the message in real time?

Is this PHP script going to run as long as the Redis sub is not timed out?

3. Some articles say that Redis's subscribe is blocking mode, some say not, in the end is not it, blocking mode is a concept?

My current script is as follows, the local test is running all the time, but I don't know if there will be any problems after the line.

two. The script for the subscription feature is subscribe.php

//subscribe.php function f($redis, $chan, $msg) {    switch($chan) {        case 'chan-1':            print "get $msg from $chan\n";            break;        case 'chan-2':            print "get $msg FROM $chan\n";            break;        case 'chan-3':            break;    }} ini_set('default_socket_timeout', -1); $redis = new Redis();$redis->pconnect('127.0.0.1',6379);$redis->setOption(Redis::OPT_READ_TIMEOUT, -1);$redis->subscribe(array('chan-1', 'chan-2', 'chan-3'), 'f');print "\n";

three. Execute script:

php subscribe.php求高人指点!

Reply content:

A. Recently in the study of Redis's Pub/sub (publish subscription feature), use the interface provided by Phpredis to manipulate data.
Current questions:
1. How to set up to solve the timeout limit of Redis subscribe?
Timeout in redis.conf configuration is 0
My Redis version:

Redis server v=3.0.4 sha=00000000:0 malloc=libc bits=64 build=ee774adfcab9032f

My version of PHP:

PHP 5.5.30 (cli) (built: Oct  3 2015 23:46:56) Copyright (c) 1997-2015 The PHP GroupZend Engine v2.5.0, Copyright (c) 1998-2015 Zend Technologies    with Xdebug v2.3.3, Copyright (c) 2002-2015, by Derick Rethans

1.1 Find the answer on the Internet, have said set PHP.ini:

But I did not succeed in this test, the direct report:

redis server went away

1.2 is currently a reference to this link, plus this configuration:

$redis->setOption(Redis::OPT_READ_TIMEOUT, -1);

The local test is always in the connected state.
2. How does the Subscriber ensure that it is running (keep running) to subscribe to the message in real time?

Is this PHP script going to run as long as the Redis sub is not timed out?

3. Some articles say that Redis's subscribe is blocking mode, some say not, in the end is not it, blocking mode is a concept?

My current script is as follows, the local test is running all the time, but I don't know if there will be any problems after the line.

two. The script for the subscription feature is subscribe.php

//subscribe.php function f($redis, $chan, $msg) {    switch($chan) {        case 'chan-1':            print "get $msg from $chan\n";            break;        case 'chan-2':            print "get $msg FROM $chan\n";            break;        case 'chan-3':            break;    }} ini_set('default_socket_timeout', -1); $redis = new Redis();$redis->pconnect('127.0.0.1',6379);$redis->setOption(Redis::OPT_READ_TIMEOUT, -1);$redis->subscribe(array('chan-1', 'chan-2', 'chan-3'), 'f');print "\n";

three. Execute script:

php subscribe.php求高人指点!
  • 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.