I. I recently studied redis's pubsub (publish subscription function) and used interfaces provided by phpredis to operate data. Currently, questions: 1. how can I solve the redissubscribe timeout limit? The timeout in the redis. conf configuration is 0. my redis version: {code...} My php...
I.Recently, we are studying redis pub/sub (publish subscription function) and using interfaces provided by phpredis to operate data.
Current questions:
1. how can I solve the timeout limit of redis subscribe?
The timeout value in the redis. conf configuration is 0.
My redis version:
Redis server v=3.0.4 sha=00000000:0 malloc=libc bits=64 build=ee774adfcab9032f
My php version:
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 The answer I found on the internet is about setting php. ini:
default_socket_time = -1
However, if this test fails, I directly report:
redis server went away
1.2 currently, this link is referenced, and this configuration is added:
$redis->setOption(Redis::OPT_READ_TIMEOUT, -1);
The local test is always in the connection status.
2. how does the subscription end ensure that the keep running is always running to subscribe to messages in real time?
Is this php script always running as long as redis sub does not time out?
3. some articles say that redis's subscribe mode is blocking mode, and some say no. Is it true? what is blocking mode?
My current script is as follows. the local test is always running, but I don't know if there will be any problems after going online.
II.The script for the subscription function 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";
III.Run the script:
Php subscribe. php!
Reply content:
I.Recently, we are studying redis pub/sub (publish subscription function) and using interfaces provided by phpredis to operate data.
Current questions:
1. how can I solve the timeout limit of redis subscribe?
The timeout value in the redis. conf configuration is 0.
My redis version:
Redis server v=3.0.4 sha=00000000:0 malloc=libc bits=64 build=ee774adfcab9032f
My php version:
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 The answer I found on the internet is about setting php. ini:
default_socket_time = -1
However, if this test fails, I directly report:
redis server went away
1.2 currently, this link is referenced, and this configuration is added:
$redis->setOption(Redis::OPT_READ_TIMEOUT, -1);
The local test is always in the connection status.
2. how does the subscription end ensure that the keep running is always running to subscribe to messages in real time?
Is this php script always running as long as redis sub does not time out?
3. some articles say that redis's subscribe mode is blocking mode, and some say no. Is it true? what is blocking mode?
My current script is as follows. the local test is always running, but I don't know if there will be any problems after going online.
II.The script for the subscription function 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";
III.Run the script:
Php subscribe. php!