Memcached is an alternative to database storage that is often useful for session storage and caching. It was developed by the guys at live journal to help them maintain their unwieldy sessions. Since then it's gained a lot of popularity among the PHP and Rails folk because it removes some of the burden on the typical database bottle neck, and allows things like session to be maintained across a cluster of servers.

First things first, you're going to need to download and make the source for libevent, which memcached has a dependency on:


tar zxf libevent-1.3d.tar.gz

cd libevent-1.3d

./configure --prefix=/usr/local

make; sudo make install; make clean;

cd ..

Once that is done, you're ready to get onto the setup and install of memcached itself:


tar zxf memcached-1.2.2.tar.gz

cd memcached-1.2.2

./configure --with-libevent=/usr/local/lib --prefix=/usr/local

make; sudo make install; make clean;

sudo /sbin/ldconfig /usr/local/lib

cd ..

And then finally, the ruby client interface:

sudo gem install memcache-client -y

Once that is installed, moving over your session store to use memcached is a breeze, simply change the setting in your environment.rb file to:

config.action_controller.session_store = :mem_cache_store