Skip to content

orionz/memcache_client

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

12 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

---------------------------------------------------------------------------

  Memcache Client in Erlang

---------------------------------------------------------------------------

  Author: Orion Henry - orion@heroku.com

  License: MIT License - http://www.opensource.org/licenses/mit-license.php

  Features:
    * text/tcp protocol support
    * binary/tcp protocol support
    * hash keys across multiple (heterogeneous) servers

---------------------------------------------------------------------------

This is a memcache client for erlang.  It is currently very much just a proof
of concept.  The interface I am sure will change over time as I get a better
and better handle on what the user experience is supposed to look like.

I have implemented both the binary protocol (very easy in Erlang!) and the
conventional text one.  The binary protocol appears to be much faster and 
have a lot of nice features missing in the text protocol but you must be
running memcache 1.4 or higher to have it supported in the server.

Given that the binary protocol is both faster, and the future, my focus has been
to make a first class implementation of the binary protocol and then try and 
coerce the text interface to work with it.

Use:

  % this connects to localhost:11211 using the text protocol
  Cache = memcache:open().

  % this connects to 10.0.0.1:11211 using the text protocol
  Cache = memcache:open([{ "10.0.0.1", 11211}], [text]).

  % this connects to 10.0.0.1:11211 using the binary protocol
  Cache = memcache:open([{ "10.0.0.1", 11211}], [binary]).

  % this connects to both 127.0.0.1:11211 and 10.0.0.1:9999 using the binary protocol
  Cache = memcache:open([{"127.0.0.1", 11211}, {"10.0.0.1",9999}], [ binary ]).

	% this adds a new cache to the connection pool
  memcache:connect(Cache, {"10.0.0.100", 11211}, [binary]).

	% this removes a cache from the connection pool
  memcache:disconnect(Cache, {"10.0.0.1", 11211} ).

	% this terminates the connection pool
  memcache:close(Cache).

  % it is possible to have a heterogenius mix of binary and text connections

  memcache:set(Cache, Key, Value).
  memcache:set(Cache, Key, Value, Flags, Expire).

  memcache:add(Cache, Key, Value).
  memcache:add(Cache, Key, Value, Flags, Expire).

  memcache:replace(Cache, Key, Value).
  memcache:replace(Cache, Key, Value, Flag, Expire).

  memcache:append(Cache, Key, Value).
  memcache:prepend(Cache, Key, Value).

  memcache:get(Cache, Key).
  memcache:getk(Cache, Key).

  memcache:increment(Cache, Key, Delta).
  memcache:decrement(Cache, Key, Delta).

  memcache:delete(Cache, Key).

  memcache:quit(Cache).

  memcache:flush(Cache).
  memcache:flush(Cache, Expires).

  memcache:noop(Cache).

  memcache:version(Cache).

  memcache:stat(Cache).
  memcache:stat(Cache, Key).

Binary Protocol:

  http://code.google.com/p/memcached/wiki/MemcacheBinaryProtocol

Text Protocol:

  http://code.sixapart.com/svn/memcached/trunk/server/doc/protocol.txt

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published