Installing Memcached
Sep 03, 2007
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:
wget http://www.monkey.org/~provos/libevent-1.3d.tar.gz
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:
wget http://www.danga.com/memcached/dist/memcached-1.2.2.tar.gz
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
Previously I led the Terraform product team @ HashiCorp, where we launched Terraform Cloud and set the stage for a successful IPO. Prior to that I was part of the Startup Team @ AWS, and earlier still an early employee @ Heroku. I've also invested in a couple of dozen early stage startups.