redis-rb
redis-rb copied to clipboard
Way to give timeout values to requests
Right now from the documentation and code it seems the only way to give a timeout value to a request is during initialization through the option hash. But If I want different timelimits for different kind of queries there doesn't seem to be a way to do that. This is useful in some scenarios where for some query you want the response very fast so you will give it a lower timelimit compared to a query for which you are happy to wait for a longer time.
I looked through the code. The client class has a with_socket_timeout
method which can do this. So, a trivial solution would be to add a method in redis class which accepts timeout limit, method name and arguments and uses the with_socket_timeout method to modify the connection timelimit. I will be happy to give a PR if you guys think this would be a good addition.