steve0511 / resty-redis-cluster

Openresty lua client for redis cluster.
Apache License 2.0
373 stars 133 forks source link

do I need to close the connection? #22

Closed moshufenmo closed 5 years ago

moshufenmo commented 5 years ago

Thanks for your code, we need it in deep.

after execute the command, do I need to close the connection manually? like keep-alived or close ? how to call these methods ? can u show some examples ?

Thanks.

steve0511 commented 5 years ago

You don't need to close the connection, client is based on lua-resty-redis and will set keep-alive by itself

steve0511 commented 5 years ago

close as of now.

moshufenmo commented 5 years ago

You don't need to close the connection, client is based on lua-resty-redis and will set keep-alive by itself

You said this client is based on lua-resty-redis, I don't need to close the connection manually, but lua-resty-redis has method named close/keep-lived, it's also a good hobbit to close the connection in time, right? if I don't close the connection in time, it will be closed during GC. Is that will impact the performance? or something else?

steve0511 commented 5 years ago

Set keep-alive itself means client has already done this job for you.(Different with lua-resty-redis) If you look at the source code of rediscluster.lua, both handleCommandWithRetry() and commit_pipeline() has already set keep alive timeout. You can configure while you init client as per guide.