nrk/phpiredis

warning in phpiredis_connect with phpiredis_command_bs

Closed this issue · 2 comments

Hi,

we dont know if it is an error, or if we are missing something:

when we connect via 127.0.0.1 all works fine, but when we connect via redis.sock, the phpiredis_command_bs() raises an warning:

$redis= phpiredis_connect("/tmp/redis.sock"); //same warning using "unix:///tmp/redis.sock"
$response = phpiredis_command_bs($redis, array('SET', 'day','monday' ));
Warning: phpiredis_command_bs() expects parameter 1 to be resource, boolean given

...and then redis is not updated.

are we missing something?

nrk commented

Hi @vanessasmith,

Unfortunately phpiredis does not support UNIX domain sockets yet, I will make sure to add this feature soon!

Also, when connecting to redis you should always check that phpiredis_connect does not return FALSE instead of a valid resource indicating that there was a problem while trying to connect to the specified server:

if (false === $redis = phpiredis_connect($host, $port)) {
    // Handle error while trying to open a new connection
}

Thanks!

nrk commented

Alright now you can just do phpiredis_connect("/tmp/redis.sock") to make use of UNIX domain sockets when connecting to Redis, the $port value if specified is simply ignored.