Skip to content

Instantly share code, notes, and snippets.

@bpoweski
Created April 9, 2010 20:46
Show Gist options
  • Save bpoweski/361571 to your computer and use it in GitHub Desktop.
Save bpoweski/361571 to your computer and use it in GitHub Desktop.
begin
memcached_config_path = File.join(Rails.root, 'config', 'memcached.yml')
if File.exists?(memcached_config_path)
# create a memcache instance with multiple servers
memcached_config = YAML::load(File::read(memcached_config_path))
args = [:mem_cache_store]
args << memcached_config[:defaults][:servers]
args << { :namespace => memcached_config[:defaults][:namespace] }
args.flatten!
ActionController::Base.cache_store = *args
ActionController::Base.perform_caching = true
end
rescue Exception => e
Rails.logger.error("failed to initialize memcache store: #{e}")
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment