Couldn’t be simpler in Rails 3.
Dalli is the new standard gem for dealing with memcached.
Gone are the days of “memcache, memcache-client, memcached” clusterfuck. Just use Dalli.
All theses steps are outlined in the Dalli README.
So if you don’t want to read the README here you go:
1. drop gem "dalli" in your Gemfile
2. In config/application.rb or config/environments/*.rb drop in config.cache_store = :dalli
3. In config/initializers/session_store.rb put the following:
require 'action_dispatch/middleware/session/dalli_store'
Rails.application.config.session_store :dalli_store, :memcache_server => ['host1', 'host2'], :namespace => 'sessions', :key => '_foundation_session', :expire_after => 30.minutes
[...] FOR RAILS3: http://awesomerails.wordpress.com/2011/08/23/rails-3-memcached-session-store/ Does rails scale? No! But memcached [...]
config.cache_store = :dalli_store
NOT
config.cache_store = :dalli