lua-resty-redis icon indicating copy to clipboard operation
lua-resty-redis copied to clipboard

init_worker_by_lua + redis - how?

Open kikito opened this issue 11 years ago • 1 comments
trafficstars

Hi there,

Is there any "legal" way to connect to redis from a worker created via the new init_worker_by_lua* directives?

Anything I try gives me the "API disabled in the context of init_worker_by_lua*" error.

kikito avatar Apr 09 '14 16:04 kikito

@kikito You cannot directly use cosockets in the context of init_worker_by_lua but you can use them in a timer created by init_worker_by_lua. See

https://github.com/chaoslawful/lua-nginx-module#ngxtimerat

The lua-resty-upstream-healthcheck library uses this trick.

agentzh avatar Apr 09 '14 18:04 agentzh