Skip to content

Instantly share code, notes, and snippets.

@thomasritz
Created August 30, 2013 09:35
Show Gist options
  • Save thomasritz/6388112 to your computer and use it in GitHub Desktop.
Save thomasritz/6388112 to your computer and use it in GitHub Desktop.
custom OpsWorks cookbook memcached.yml.erb that supports memcached cluster
# rails/templates/default/memcached.yml.erb
<%
instances = node[:opsworks][:layers][:memcached][:instances]
instances = {:localhost => {:private_ip => "127.0.0.1"}} if instances.empty?
-%>
hosts:
<% instances.each_pair do |name, cache_server| -%>
- "<%= cache_server[:private_ip]%>:<%= @memcached[:port] %>"
<% end -%>
# config/environments/production.rb
MyProject::Application.configure do
# ...
memcached_config = YAML.load_file(Rails.root + 'config/memcached.yml')
memcached_hosts = memcached_config['hosts']
config.cache_store = :dalli_store, *memcached_hosts,
{
namespace: 'myproject',
expires_in: 1.day,
compress: true,
}
# ...
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment