Skip to content

memcachier/examples-rails3-heroku

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

25 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

MemCachier Rails 3 Example App

This is an example Rails 3 application that demonstrates the use of caching using the MemCachier addon on Heroku. This example is written with Rails 3.2.

You can read the full text of the Heroku Dev Center article here. Update: This article is now updated for Rails 5. The corresponding example app is here.

You can see this app in action on Heroku here.

Deploy to Heroku

You can deploy this app yourself to Heroku to play with.

Deploy

Setup MemCachier

Setting up MemCachier to work in Rails is very easy. You need to make changes to Gemfile, production.rb, and any app code that you want cached. These changes are covered in detail below.

Gemfile

MemCachier has been tested with the dalli memcache client. Add the following Gem to your Gemfile:

gem 'memcachier'
gem 'dalli'

Then run bundle install as usual.

Note that the memcachier gem simply sets the appropriate environment variables for Dalli. You can also do this manually in your production.rb file if you prefer:

ENV["MEMCACHE_SERVERS"] = ENV["MEMCACHIER_SERVERS"]
ENV["MEMCACHE_USERNAME"] = ENV["MEMCACHIER_USERNAME"]
ENV["MEMCACHE_PASSWORD"] = ENV["MEMCACHIER_PASSWORD"]

Alternatively, you can pass these options to config.cache_store (also in production.rb):

config.cache_store = :dalli_store, ENV["MEMCACHIER_SERVERS"],
                    {:username => ENV["MEMCACHIER_USERNAME"],
                     :password => ENV["MEMCACHIER_PASSWORD"]}

production.rb

Ensure that the following configuration option is set in production.rb:

config.cache_store = :dalli_store

Using MemCachier

In your application, use Rails.cache methods to access MemCachier. A list of methods is available here. All the built-in Rails caching tools will work, too.

Get involved!

We are happy to receive bug reports, fixes, documentation enhancements, and other improvements.

Please report bugs via the github issue tracker.

Master git repository:

  • git clone git://github.com/memcachier/examples-rails3-heroku.git

Licensing

This library is BSD-licensed.

Releases

No releases published

Packages

No packages published

Languages

  • Ruby 70.0%
  • HTML 21.1%
  • CSS 5.9%
  • JavaScript 2.2%
  • CoffeeScript 0.8%