ngx.shared.DICT serialize / deserialize

Yichun Zhang (agentzh) agentzh at gmail.com
Sat Nov 11 21:30:36 UTC 2017


Hello!

On Thu, Nov 9, 2017 at 12:19 PM, Joel Parker wrote:
> I am trying to load a table from disk (deserialize) into memory and then
> add, change, remove the values in the table then write it periodically back
> to disk (serialize). I looked at the documentation for the ngx.shared.DICT
> (https://github.com/openresty/lua-nginx-module#ngxshareddict) and it seems
> like it would fit my needs but I do not see anywhere in the documentation
> how to load the table initially from disk and modify then write back to
> disk. Could someone provide a basic example of how I might accomplish this ?
>

You need to do serialization and persistence support yourself (like
using lua-cjson/lua-msgpack for serialization and the standard Lua io
module for file reads/writes). These are not built into the shdict API
directly. BTW, better post such questions to the openresty-en mailing
list:

    https://openresty.org/en/community.html

Best regards,
Yichun


More information about the nginx mailing list