Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to close or reset a pconnect() connection when using PHPRedis and PHP-FPM?

Using PHPRedis and Apache PHP-FPM I'm using the pconnect() call to re-use connections - its been helpful in past to not let the number of connections creep up too high. However in the case where our primary redis node goes down - we automatically promote the slave to master and the old master becomes read-only. The pconnect() however is still holding a connection to the old maste - so set() commands begin to fail.

What we need is a way to tear down those persistent connections without killing the process. Any ideas?

like image 526
asolberg Avatar asked Oct 02 '15 21:10

asolberg


1 Answers

in phpredis 4.3.0, close() can close connection created by pconnect(). if you use redis method after close(), a new persistent connection will be auto created.

like image 132
sun Avatar answered Oct 03 '22 00:10

sun