Hello!
On Fri, Feb 28, 2014 at 3:38 PM, ssimpson wrote:
> I'm using lua-resty-redis with nginx to talk to a redis server. The manual
> page for lua-resty-redis shows a call so so_keepalive to return the
> connection to the pool at the end of the example program. It doesn't show a
> call to so_keepalive for an error return.
You mean "set_keepalive" instead of "so_keepalive" here, right?
Yes, you should only put a good connection into the pool.
> Does this call need to be done for
> all returns?
Nope, just for code paths you can safely reuse the connections. Also
keep in mind that Redis connections can carry state, as in pub/sub
mode. Reusing stateful Redis connections requires special caution.
> Is the connection returned to the connection pool automatically
> when the lua script runs out of scope? Thank you.
>
The connection is automatically shut down when the cosocket object is
collected. The decision has been made that blindly putting unused
connections into the pool is a dangerous thing to do. In many cases,
only the user knows whether the current connection is safe to get
reused.
Best regards,
-agentzh