Getting Heroku, memcached and Rails 3 working

Mon Sep 13 02:41:29 -0700 2010

The docs for Heroku and memecached do not cover Rails 3. So here is the short version:

In your Gemfile:

group :production do
  gem "memcache-client"
  gem 'memcached-northscale', :require => 'memcached'
end

In your environment.rb:

config.cache_store = :mem_cache_store, Memcached::Rails.new

Told you it was short.

Oh, and remember to install the memcached add on to your app:

heroku addons:add memcache:5mb

Told you it was short.

blogLater

Mikel

  1. Ramin Says:

    I actually had to define the config.cache_store = :mem_cache_store, Memcached::Rails.new inside my config/environments/production.rb to get this to work.

  2. Ramin Says:

    I actually had to define the config.cache_store = :mem_cache_store, Memcached::Rails.new inside my config/environments/production.rb to get this to work.

  3. aokudsrm Says:

    Helpful note: memcached-northscale doesn’t work with Ruby 1.9.2. And since Rails3 is unstable on Ruby 1.9.1, you’re probably going to have to go with 1.8.7

  4. Joost Schuur Says:

    @W. Andrew: I couldn’t get dalli to work on Heroku without explicitly specifying the memcached server environment variable in the config line like this:

    config.cache_store = :dalli_store, ENV[‘MEMCACHE_SERVERS’]

    Props go to http://arailsdemo.com for pointing that out to me after some frustrating and futile debugging.

  5. Kate Says:

    Helpful note: memcached-northscale doesn’t work with Ruby 1.9.2. And since Rails3 is unstable on Ruby 1.9.1, you’re probably going to have to go with 1.8.7

  6. jc Says:

    Agreed, memcached-northscale is still busted in 1.9.2. Thanks to W. Andrew for the dalli suggestion. That worked as a great alternative.

  7. W. Andrew Loe III Says:

    Better yet, use dalli. It is considerably easier to hook for monitor and fast enough for all but the most demanding apps (uses the binary protocol but implemented entirely in Ruby).

    http://github.com/mperham/dalli

    1. Gemfile
      gem ‘dalli’
    1. environments/production.rb
      config.cache_store = :dalli_store
  8. fdsg3tgfv Says:

    Helpful note: memcached-northscale doesn’t work with Ruby 1.9.2.why am i always tired And since Rails3 is unstable on Ruby 1.9.1, you’re probably going to have to go with 1.8.7 Fatigue Symptoms

Leave a Reply