Rails and caching, is it easy to switch between memcache and redis?

Blankman picture Blankman · Nov 19, 2010 · Viewed 15.5k times · Source

Is there a common api such that if I switch between Redis or Memcached I don't have to change my code, just a config setting?

Answer

Simone Carletti picture Simone Carletti · Nov 19, 2010

As long as you don't initialize the Memcached client yourself but you rely on Rails.cache common API, switching from Memcached to Redis is just a matter of installing redis-store and changing the configuration from

config.cache_store = :memcached_store

to

config.cache_store = :redis_store

More info about Rails.cache.