From 7f2346650fbaca6213864c5aaaae60e7d34d3807 Mon Sep 17 00:00:00 2001 From: James Mason Date: Fri, 17 Nov 2017 18:32:08 -0800 Subject: [PATCH] Configure cache stores rely on RAM caching for devel, and optionally a memcached server in production --- Gemfile | 3 +++ Gemfile.lock | 2 ++ config/environments/development.rb | 2 ++ config/environments/production.rb | 8 ++++++++ 4 files changed, 15 insertions(+) diff --git a/Gemfile b/Gemfile index 69e750d4..e624a1f7 100644 --- a/Gemfile +++ b/Gemfile @@ -214,6 +214,9 @@ gem 'selectize-rails' # CVE-2017-9049, CVE-2017-9050 gem 'nokogiri', '>= 1.8.1' +# memcached binary connector +gem 'dalli' + # Use guard and spring for testing in development group :development do # to launch specs when files are modified diff --git a/Gemfile.lock b/Gemfile.lock index 17c25857..1645c8be 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -145,6 +145,7 @@ GEM safe_yaml (~> 1.0.0) currencies (0.4.2) daemons (1.1.9) + dalli (2.7.6) dante (0.2.0) database_cleaner (1.3.0) debug_inspector (0.0.3) @@ -597,6 +598,7 @@ DEPENDENCIES country_select coveralls daemons + dalli database_cleaner delayed_job_active_record devise diff --git a/config/environments/development.rb b/config/environments/development.rb index 2557e892..4bff137e 100644 --- a/config/environments/development.rb +++ b/config/environments/development.rb @@ -12,6 +12,8 @@ Osem::Application.configure do # since you don't have to restart the web server when you make code changes. config.cache_classes = false + config.cache_store = :memory_store, { size: 64.megabytes } + # Show full error reports and disable caching config.consider_all_requests_local = true config.action_controller.perform_caching = false diff --git a/config/environments/production.rb b/config/environments/production.rb index cf598a16..11a8c06b 100644 --- a/config/environments/production.rb +++ b/config/environments/production.rb @@ -46,6 +46,14 @@ Osem::Application.configure do # Use a different cache store in production # config.cache_store = :mem_cache_store + if ENV["MEMCACHEDCLOUD_SERVERS"] + config.cache_store = :dalli_store, ENV["MEMCACHEDCLOUD_SERVERS"].split(','), { + username: ENV["MEMCACHEDCLOUD_USERNAME"], + password: ENV["MEMCACHEDCLOUD_PASSWORD"] + } + else + config.cache_store = :memory_store, { size: 64.megabytes } + end # Enable serving of images, stylesheets, and JavaScripts from an asset server # config.action_controller.asset_host = "http://assets.example.com"