I installed redis 2.8.12 and configured phpredis. Then I called redis instance in php class. But there is no result, can you help me?
public function __construct() {
try {
echo ':) ';
$newRedis = new Redis();
echo ':P ';
}
catch (Exception $e) {
echo $e -> getMessage();
}
}
this printed :), not printed :P
You can try to use RedisException class to debug your redis connection.
try{
if( $socket = fsockopen( $host, $port, $errorNo, $errorStr )){
if( $errorNo ){
throw new RedisException(“Socket cannot be opened”);
}
}
}catch( Exception $e ){
echo $e -> getMessage( );
}
I will elaborate on the answer once you are able to give an exception or an error.
Did you check if your php redis module is loaded by checking in phpinfo() ? Also, if your redis server is running properly and on which port and if configured using password you are supplying same while initiating the connection ?
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.