[Redis] Redis client: Timeouts !

Damien Krotkine dkrotkine at gmail.com
Fri Dec 27 11:23:18 GMT 2013





Le 27 déc. 2013 à 08:40, Celogeek San <me at celogeek.com> a écrit :

> Hi. What happen in case of read timeout?
> Did you close the connexion?
> 
> If I read a data with a very long time to response.
> So I have a read time out.
> And then I do another command.
> It is possible if the socket had not been flush to receive the precedent command
> 
Yes indeed. Contrary to a previous implementation ( where the socket was closed for you), this implementation doesn't do anything for you on the socket. When a timeout is hit, Redis.pm throws an exception and $! Is set. You should then close the connection and retry. 

In theory, if the timeout was hit while writing, you could retry with the same socket, because you can be reasonably  site that the command didn't hit the server. However, I don't think Redis exceptions will make it clear if it was while reading or writing. There is a ticket on github to implement better exceptions. 


> Le 26 déc. 2013 23:28, "Damien Krotkine" <damien at krotkine.com> a écrit :
> Hi,
> 
> I've just pushed new code in the git master branch. It contains timeouts
> related features. Now you can creates a Redis client with connection,
> read and write timeouts:
> 
> my $redis = Redis->new(
>     cnx_timeout => 60,      # connection timeout (in seconds)
>     read_timeout => 0,5,    # read timeout (in seconds)
>     write_timeout => 1.2,    # write timeout (in seconds)
> );
> 
> I haven't yet released it on CPAN, I'd like to do a developer release
> first (but I'm not sure how to do that with dzil). Anyway please feel
> free to test it and let me know of any issues. The code uses 2
> strategies, on mac and linux it uses setsockopt to set read / write
> timeouts, on other OS it uses 'select'. I plan to extend the setsockopt
> strategies to more OS.
> 
> dams.
> 
> 
> _______________________________________________
> Redis mailing list
> Redis at lists.scsys.co.uk
> http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/redis
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.scsys.co.uk/pipermail/redis/attachments/20131227/0ce7732e/attachment.htm


More information about the Redis mailing list