Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
An Erlang Memcached Client.
Erlang Perl
branch: master

This branch is 62 commits ahead of jdacronym:master

Fetching latest commit…

Cannot retrieve the latest commit at this time

Failed to load latest commit information.
src
t
.gitignore
Emakefile
LICENSE.txt
Makefile
NOTICES
README
rebar

README

merle : An erlang based memcached client.

Modified by Pablo Polvorin from Joe Williams original at
http://github.com/joewilliams/merle/

Usage:

%2 memcached instances, pool of 5 connections to each.
merle_sup:start_link([ ["localhost", 11211], 
			["localhost", 11212 ]], 5).

S = merle_cluster_dynamic:get_server("SomeClusteringKey"),
P = local_pg2:get_closest_pid(S),
merle:getkey(P, "key").


If a memcached node goes down, connections to it will be retried
each 15".  *Cluster keys aren't re-hashed*, they simple fail while the
cache node is down.  
The cluster key may be different than the search key.
It isn't possible to add/remove memcached nodes on the fly, no 
consistent hashing mechanism is used.
-------------------------------------------------------------------


Version : 0.3

Author : Joe Williams <joe@joetify.com>
Contributors : Nick Gerakines <nick@gerakines.net>

Info : http://github.com/joewilliams/merle/

merle uses LShift's gen_server2 module/behavior for faster message queues.
http://hg.rabbitmq.com/rabbitmq-server/file/b95f2fd4e3f6/src/gen_server2.erl

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


Features:
* Support for stats, version, getkey, getskey, delete, set, add, replace, cas, flushall, verbosity, incr and decr (with specially set "counter" keys)

Notes:
* Uses term_to_binary and binary_to_term to serialize/deserialize Erlang terms before sending/receiving them. This allows for native Erlang terms to be returned from memcached but doesn't play well using other languages after setting values with merle or using merle to get values set by other languages.
* getkey and getskey currently don't work on keys initialized with addcounter/1. The binary data you get back won't be a serialized erlang integer, and so the implicity binary_to_term done by getkey and getskey provokes disaster.

Merle Based Projects:

http://github.com/cstar/merle
http://github.com/issuu/merle
http://github.com/0lvin/merle
http://github.com/ppolv/merle

Usage:

* Connecting to memcached *

Using defaults:

> merle:connect().

Set your own:

> merle:connect("HOSTNAME", 11211).


* A few operations *

> merle:set(a, asdf).
ok
> merle:getkey(a).
asdf

> merle:set(a, asdf).
ok
> merle:getskey(a).
[4,asdf]
> merle:cas(a, 4, asdfasdf).
ok
> merle:getskey(a).
[5,asdfasdf]

> merle:delete(a).
ok

* Informational commands *

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

> merle:stats(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 active_slabs 1",
 "STAT total_malloced 1048528","END"]

> merle:stats().
["STAT pid 27195","STAT uptime 497","STAT time 1232843046",
 "STAT version 1.2.6","STAT pointer_size 64",
 "STAT rusage_user 0.000000","STAT rusage_system 0.008000",
 "STAT curr_items 1","STAT total_items 5","STAT bytes 83",
 "STAT curr_connections 2","STAT total_connections 5",
 "STAT connection_structures 3","STAT cmd_get 5",
 "STAT cmd_set 5","STAT get_hits 5","STAT get_misses 0",
 "STAT evictions 0","STAT bytes_read 216",
 "STAT bytes_written 468","STAT limit_maxbytes 67108864",
 "STAT threads 1","END"]

> merle:addcounter("my_counter").
ok
> merle:incr("my_counter",0).
{ok,0}
> merle:incr("my_counter",12).
{ok,12}
> merle:addcounter("my_counter").
ok
> merle:incr("my_counter",12).
{ok,24}
> merle:decr("my_counter",30).
{ok,0}
> merle:incr("nonexistent_counter",0).
not_found
> merle:delete("my_counter").
ok
> merle:delete("my_counter").
not_found

Something went wrong with that request. Please try again.