nrk / phpiredis

PHP extension for Redis based on Hiredis
BSD 2-Clause "Simplified" License
490 stars 66 forks source link

warning in phpiredis_connect with phpiredis_command_bs #30

Closed vanessasmith closed 10 years ago

vanessasmith commented 10 years ago

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 10 years ago

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 10 years ago

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.