连接服务器的简单脚本:
#include "hiredis.h"
int main(void) {
int fd;
unsigned int j;
redisReply *reply;
reply = redisConnect(&fd, "test.com", 6379);
if (reply != NULL) {
printf("Connection error: %s", reply->reply);
exit(1);
}
reply = redisCommand(fd,"PING");
printf("PONG: %s\n", reply->reply);
freeReplyObject(reply);
}
如果服务器可用- 一切正常。如果没有 - 有很长的停顿。例如,如何将等待时间减少到 2 秒?