[Redis] Redis client: Timeouts !
Steffen Mueller
smueller at cpan.org
Thu Dec 26 23:30:54 GMT 2013
Hi dams,
On 12/26/2013 11:28 PM, Damien Krotkine wrote:
> 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.
Reading the change and having another look at IO::Socket::Timeout, I
have some concerns about the implementation. IO::Socket::Timeout
implements a function "new::with::timeout" (and
socketpair::with::timeout) which is then to be called as a fully
qualified method on a compatible class.
That's a real hack. For those reading along that might not immediately
see what's going on: This completely bypasses method dispatch and
subverts Perl's object model. new::with::timeout is the "timeout"
function in the "new::with" namespace. $class->new::with::timeout is
exactly the same as calling a fully qualified function with a string
argument "new::with::timeout($class)". There's not method dispatch
happening and another namespace is somewhat subtly polluted.
Surely, there's a less invasive and less
likely-to-make-somebody-lose-days-debugging way of implementing this?
--Steffen
More information about the Redis
mailing list