Monday, August 27, 2007

anatomy of a memcached daemon

Before you start experimenting with memcached, here's a quick description of the command line options that will be used when starting it up. (note there is no configuration file for memcached).

It seems as if the most common command line options are used: -l -d -p -m -c

Here is what each of them do, per the memcached man pages:

-l
Listen on ; default to INDRR_ANY. This is an important
option to consider as there is no other way to secure the
installation. Binding to an internal or firewalled network
interface is suggested.

-d Run memcached as a daemon.

-m
Use MB memory max to use for object storage; the default
is 64 megabytes.

-c
Use max simultaneous connections; the default is 1024.

-p
Listen on TCP port , the default is port 11211.

Here is an example command line script to fire up memcached with some options:

$ memcached -d -m 128 -l 10.0.0.40 -p 11211
This will start memcached as a daemon, allocate 128 MB memory max for storage of the memcached hashed query, listen on ip address 10.0.0.40, and listen on TCP port 11211.

So that's all there is to starting the daemon with a variety of options. Note there are more options in the man pages, but the above options are enough to give it a whirl. If you ever need to stop your memcached daemons, issue the following command:
$ killall memcached
Here is a couple helpful posts of using memcached with Rails:

http://townx.org/rails_and_memcached

http://nubyonrails.com/articles/2006/08/17/memcached-basics-for-rails

http://avoir.uwc.ac.za/avoir/index.php?module=wiki&pagename=MemcachedInstallDebianEtch&action=wikilink

2 comments:

Anonymous said...

Quick and useful, thanks for posting this..

Ideation Fashion said...

Good sharing of this nice post. Thanks.
hermes lindy bag