Skip to content
An Erlang Memcached Client.
Erlang Perl
Find file
New pull request
Fetching latest commit...
Cannot retrieve the latest commit at this time.
Failed to load latest commit information.


merle : An erlang based memcached client.

Version : 0.1
Author : Joe Williams <>
Blog :
Info :

This code is available as Open Source Software under the MIT license.

* Support for stats, version, get, delete, set, add, replace, cas
* Supports making calls to memcached directly as well as through gen_server

To Do:
* The noreply option and the append, prepend, increment and decrement commands will likely be added in the future
* Support for retrieving multiple keys at once
* Socket pool/reuse


$ cd /some/erlang/lib/location/
$ tar zxvf merle-VERSION.tar.gz
$ cd merle-VERSION
$ make
$ erl
> merle:module_info().

This should display info about merle if installd correctly.


* Start it up *

2> merle:start_link("localhost", 11211).

* Set and get some data *

9> merle:set("b", "1", "0", [asdf,[{asdf, asdf}, asdf]]).
10> merle:get("b").

* Get the memcached version *

11> merle:version().
["VERSION 1.2.6"]

* Get memcached stats *

12> merle:stats().
["STAT pid 12177","STAT uptime 6146","STAT time 1231993128",
 "STAT version 1.2.6","STAT pointer_size 64",
 "STAT rusage_user 0.008000","STAT rusage_system 0.000000",
 "STAT curr_items 2","STAT total_items 2",
 "STAT bytes 128976","STAT curr_connections 2",
 "STAT total_connections 3","STAT connection_structures 3",
 "STAT cmd_get 3","STAT cmd_set 2","STAT get_hits 3",
 "STAT get_misses 0","STAT evictions 0",
 "STAT bytes_read 128911","STAT bytes_written 257735",
 "STAT limit_maxbytes 67108864","STAT threads 1","END"]

* Get stats with arguments *

145>  merle:stats("localhost", 11211, "slabs").
["STAT 1:chunk_size 104","STAT 1:chunks_per_page 10082",
 "STAT 1:total_pages 1","STAT 1:total_chunks 10082",
 "STAT 1:used_chunks 10081","STAT 1:free_chunks 1",
 "STAT 1:free_chunks_end 10080","STAT 21:chunk_size 10320",
 "STAT 21:chunks_per_page 101","STAT 21:total_pages 1",
 "STAT 21:total_chunks 101","STAT 21:used_chunks 101",
 "STAT 21:free_chunks 0","STAT 21:free_chunks_end 100",
 "STAT active_slabs 2","STAT total_malloced 2090848","END"]

* Direct memcached call example *

13> merle:set("localhost", 11211, "a", "1", "0", asdf).
14> merle:get("localhost", 11211, "a").


start_link(Host, Port)


stats(Host, Port)


stats(Host, Port, Args)


version(Host, Port)


get(Host, Port, Key)

delete(Key, Time)

delete(Host, Port, Key, Time)

set(Key, Flag, ExpTime, Data)

set(Host, Port, Key, Flag, ExpTime, Data)

add(Key, Flag, ExpTime, Data)

add(Host, Port, Key, Flag, ExpTime, Data)

replace(Key, Flag, ExpTime, Data)

replace(Host, Port, Key, Flag, ExpTime, Data)

cas(Key, Flag, ExpTime, CasUniq, Data)

cas(Host, Port, Key, Flag, ExpTime, CasUniq, Data)

Something went wrong with that request. Please try again.