0

I'm using redigo (github.com/gomodule/redigo/redis) to evaluting some lua scripts on redis.

However, I read the related GoDoc, I can't find any methods to set a timeout when evaluating a lua script using the redis.Script type. The Script.Do method call the conn.Do method, which doesn't set a timeout. Is there any methods that I can use to set a timeout limit when I'm evaluting a lua script?

xianye
  • 1
  • you could use a channel and have timeouts but.. i don't think its gonna be effective as you cant close the channel.. you could try modifying the source code and add a timeout option .. – Siva Guru Apr 25 '20 at 09:20
  • Can't you use [ConnWithTimeout](https://pkg.go.dev/github.com/gomodule/redigo/redis?tab=doc#ConnWithTimeout) and pass it to `script.Do()`? – Emile Pels Apr 25 '20 at 10:22
  • Use the connection's [default read timeout](https://godoc.org/github.com/gomodule/redigo/redis#DialReadTimeout) for scripts. If that does not work for your application, then explain why it does not work. Note that it's not a good idea to execute slow Redis scrirpts. – Charlie Tumahai Apr 25 '20 at 12:46
  • I don't know how to use ConnWithTimeout and pass it to script.Do(). Can you give me a simple example? I just want to set different timeout limits for different lua scripts. – xianye Aug 28 '20 at 07:46

0 Answers0