9951 explained code solutions for 126 technologies


php-redisHow to auto reconnect to Redis


Since Redis client supports automatic reconnect and has it enabled by default, we should just use standard connection method:

$r = new Redis();
$r->connect('127.0.0.1', 6379);
// work with $r even if server goes away and returnsctrl + c
new Redis()

create Redis object

connect(

connect to specified host and port