Created
August 30, 2013 09:35
-
-
Save thomasritz/6388112 to your computer and use it in GitHub Desktop.
custom OpsWorks cookbook memcached.yml.erb that supports memcached cluster
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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 -%> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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