MemCachier Rails Usage Example
Ruby HTML JavaScript CSS
Latest commit 0915c8d Mar 28, 2016 @dterei dterei Remove vendor plugins
Failed to load latest commit information.
app Update to style. Jun 7, 2013
config Use puma webserver Mar 28, 2016
db Empty rails project. Apr 2, 2012
lib Empty rails project. Apr 2, 2012
log Empty rails project. Apr 2, 2012
public App is working, just not with caching yet. Apr 2, 2012
script Empty rails project. Apr 2, 2012
test Empty rails project. Apr 2, 2012
.gitignore Add kgio and increase timeout. Aug 29, 2012
Gemfile
Gemfile.lock Add puma gem Mar 28, 2016
LICENSE
Procfile
README.md Add deploy to heroku option. Aug 5, 2014
Rakefile Empty rails project. Apr 2, 2012
app.json Update heroku deploy button Mar 28, 2016
config.ru Empty rails project. Apr 2, 2012

README.md

MemCachier Rails Example App

This is an example Rails app that uses MemCachier to GIS lookups. This example is written with Rails 3.2.

You can view a working version of this app here. Running this app on your local machine in development will work as well, although then you won't be using MemCachier -- you'll be using a local dummy cache. MemCachier is currently only available with various cloud providers.

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"].split(','),
                    {: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.

Take a look at app/controllers/home_controller.rb in this repository for an example.

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-rails.git

Licensing

This library is BSD-licensed.