openresty/lua-resty-memcached

How to decode deflate data from memcached?

Yahook opened this issue · 4 comments

Hello,

I put data to memcached from php, it automatically uses a compression of data if it's size is too large. It allows to save a lot of space.

But when I try to read this data from resty.memcached I see compressed data and I have no idea how to decompress it. Could you please suggest me a solution which can help me?

Best regards,
Yahook

If you know what flag php sets, then you can check if this flag is set then
uncompress in your Lua.

I know a compression algorithm, it's deflate. But I don't know how to decompress it in Lua. I would appreciate very much if you could show me an example how to do that.

Thanks,
Yahook

There's various zlib bindings out there for Lua. Just choose one that works for you. For example,

https://github.com/LuaDist/lzlib

Thanks, I will try it.