mcd is a memcached compatible API server written in Erlang/OTP 25 using ETS to maintain the cache of data.
It has a TCP memcached compatible API on port 11211 offering:
- the original text based standard protocol;
- the binary protocol;
- the text based meta protocol (which also deprecates the binary protocol).
mcd uses erlang.mk with Erlang/OTP 25 to build:
make
To run mcd with an Erlang Shell listening on port 11211:
make shell
To run mcd as a docker container:
docker run \
--pull always \
--detach \
--publish 11211:11211 \
--rm \
ghcr.io/shortishly/mcd:latest
The text based API is the easiest to try out from the command line with a simple set and get:
telnet localhost 11211
Trying 127.0.0.1...
Connected to localhost.
Escape character is '^]'.
set foo 0 0 6
fooval
STORED
get foo
VALUE foo 0 6
fooval
END
The implementation uses some recently introduced features of Erlang/OTP:
- socket for all communication
- send_request for asynchronous request and response.
- the timeout feature of statem to expire items from the cache.