2013-04-30 25 views
2

redisGetReply可以有超时时间吗? 我当前的代码是redisGetReply的超时时间

while(redisGetReply(context,&reply) == REDIS_OK) { 
     //Check for isstopped 
     if yes return  
     // consume message 
     freeReplyObject(reply); 
    } 

目前,如果I信号SIGINT给程序。目前,如果我在redisGetReply中发信号通知SIGINT和此线程。它将等待,直到有来自服务器的消息。

如何使redisGetReply停止某些siganl或有readreply超时?

回答

0

正如你可以只调用redisGetReply

struct timeval tv = { 0, 1000 }; 
assert(redisSetTimeout(c,tv) == REDIS_OK); 
test_cond(redisGetReply(c,&_reply) == REDIS_ERR && 
     c->err == REDIS_ERR_IO && errno == EAGAIN); 
redisFree(c); 
之前在这个环节

Testing hiredis example

您可以设置超时见