Heroku Configuration

Mike Perham edited this page Sep 14, 2013 · 7 revisions

To get Dalli to use the Heroku memcache server, you need do nothing special in your configuration - Dalli will pick up the MEMCACHE_SERVERS environment variable and use those server(s).

# config/environments/production.rb
config.cache_store = :dalli_store

# Gemfile
gem 'dalli'


You can also use Dalli with Sinatra, via rack-cache or independently.

require 'dalli'
set :cache, Dalli::Client.new

# use the settings convention to access your cache
settings.cache.set('color', 'blue')

Just like with Rails, Dalli will automatically pick up Heroku's MEMCACHE environment variables. However if you need to setup something specific, such as an expires_in option, here's how:

    :username => ENV['MEMCACHE_USERNAME'], 
    :password => ENV['MEMCACHE_PASSWORD'], 
    :expires_in => 300)

See also

Heroku Docs on Memcache
Heroku Developer Center - Using Rack::Cache With Memcached for Static Assets in Rails 3.1+

Clone this wiki locally
You can’t perform that action at this time.
You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session.
Press h to open a hovercard with more details.