Welcome! Log In Create A New Profile

Advanced

ngx.shared.DICT serialize / deserialize

Posted by Joel Parker 
Joel Parker
ngx.shared.DICT serialize / deserialize
November 09, 2017 09:30PM
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 ?

Joel
_______________________________________________
nginx mailing list
nginx@nginx.org
http://mailman.nginx.org/mailman/listinfo/nginx
Yichun Zhang (agentzh)
Re: ngx.shared.DICT serialize / deserialize
November 11, 2017 10:40PM
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
_______________________________________________
nginx mailing list
nginx@nginx.org
http://mailman.nginx.org/mailman/listinfo/nginx
Sorry, only registered users may post in this forum.

Click here to login