Hello!
On Mon, Mar 3, 2014 at 10:34 AM, Aapo Talvensaari wrote:
> Right now, lua-resty-template caches compiled template functions is a
> lua-table, but I'm not sure if that is a way to go.
You can either let your user cache the template himself or cache
automatically in your template engine.
You can implement a simple LRU cache atop Lua tables (and FFI cdata).
This can be a separate Lua library I suppose.
> And even bigger problem with
> large number of workers (not sharing cache). That's why I'm looking for
> alternatives.
>
You cannot share Lua code across the process boundary (or the Lua VM
boundary). It will not be cheaper than compiling your template string
again.
> I see there is this:
> http://wiki.nginx.org/HttpLuaModule#ngx.shared.DICT
>
No, you need serialize and deserialize the compiled Lua closure
yourself, which has its own overhead. Keep in mind you're going across
the process boundary. And compiled Lua closures are essentially a
bunch of binary data strucutres (GCproto, GCfunc, and even with
GCtrace and machine code area) interleaved with the rest of the VM.
> All my messages go deleted immediately.