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求高人指点!