Lua memcached provides a binding for memcached, a high-performance, distributed memory object caching system. The module is implemented in C using the binary protocol and includes a codec for encoding and decoding Lua values.
Here is a quick example:
local memcached = require("memcached")
local function makeValue ()
-- ... some logic, such as a database query ...
return {
hello = "world"
}
end
local client = memcached.open()
local key = "my-key"
local value = client:get(key)
if not value then
value = makeValue()
client:set(key, value, 60)
end
print(value.hello)To build and install with LuaRocks, run:
luarocks install lua-memcached
Lua memcached comes with a simple Makefile. Please adapt the Makefile to your environment, and then run:
make
make test
make install
Please see the release notes document.
Please see the documentation folder.
Lua memcached supports Lua 5.3 and Lua 5.4.
Lua memcached has been built and tested on Ubuntu Linux (64-bit).
Lua memcached supports a (relevant) subset of memcached commands.
Lua memcached's default encoder function limits buffers to 256 megabytes.
Lua memcached is released under the MIT license. See LICENSE for license terms.