Hello!
On Fri, Sep 25, 2015 at 11:17 PM, Martin Gee wrote:
> I know global var in lua are bad. My understanding is set_by_lua runs each
> time to. I cant use init_by_lua since this is location specific.
>
> Is there a way to statically define this map in standard nginx conf or lua?
>
There are more than one way to do it, depending on your requirements. See
https://github.com/openresty/lua-nginx-module#data-sharing-within-an-nginx-worker
and
https://github.com/openresty/lua-nginx-module#lua_shared_dict
For the first approach based on custom Lua modules, you can preload it
in init_by_lua and any subsequent request-time require() will just use
the already loaded version (which may also enjoy the COW feature of
modern OSes). The same trick applies to the second approach based on
shm (you can initialize lua_shared_dict in init_by_lua* too).
Oh, please do not cross-post. It's annoying. Thanks for your cooperation.
Regards,
-agentzh