# the following code, or similar, will detect whether memcached is running # and, iff so, use that for the Rails.cache. it gracefully falls back to # using the built in MemoryStore if memcached is not running # has_memcached = begin MemCache.new('localhost').get('42') true rescue Object => e Rails.logger.error e Rails.logger.warn "** NO MEMCACHED FOUND **" false end if has_memcached cache = ActiveSupport::Cache.lookup_store(:mem_cache_store) Object.send(:remove_const, "RAILS_CACHE") Object.send(:const_set, "RAILS_CACHE", cache) ActionController::Base.cache_store = cache end