Merge pull request #7648 from Matt-Yorkley/redis

Switch cache store from memcached to redis
This commit is contained in:
Andy Brett
2021-05-19 10:36:20 -07:00
committed by GitHub
6 changed files with 27 additions and 9 deletions

View File

@@ -82,6 +82,9 @@ gem 'rack-rewrite'
gem 'rack-ssl', require: 'rack/ssl'
gem 'roadie-rails', '~> 2.2.0'
gem 'redis', '>= 4.0', require: ['redis', 'redis/connection/hiredis']
gem 'hiredis'
gem 'combine_pdf'
gem 'wicked_pdf'
gem 'wkhtmltopdf-binary'

View File

@@ -285,6 +285,7 @@ GEM
tilt
hashdiff (1.0.1)
highline (2.0.3)
hiredis (0.6.3)
i18n (1.8.10)
concurrent-ruby (~> 1.0)
i18n-js (3.8.2)
@@ -447,6 +448,7 @@ GEM
rb-inotify (0.10.1)
ffi (~> 1.0)
redcarpet (3.5.1)
redis (4.2.5)
regexp_parser (2.1.1)
request_store (1.5.0)
rack (>= 1.4)
@@ -672,6 +674,7 @@ DEPENDENCIES
good_migrations
haml
highline (= 2.0.3)
hiredis
i18n
i18n-js (~> 3.8.2)
immigrant
@@ -706,6 +709,7 @@ DEPENDENCIES
rails_safe_tasks (~> 1.0)
ransack (= 2.4.1)
redcarpet
redis (>= 4.0)
responders
roadie-rails (~> 2.2.0)
roo (~> 2.8.3)

View File

@@ -66,5 +66,3 @@ SMTP_PASSWORD: 'f00d'
# config/initializers/feature_toggles.rb for details.
#
# BETA_TESTERS: ofn@example.com,superadmin@example.com
MEMCACHED_VALUE_MAX_MEGABYTES: '4'

View File

@@ -11,7 +11,14 @@ Openfoodnetwork::Application.configure do
config.cache_classes = !!ENV["PROFILE"]
# :file_store is used by default when no cache store is specifically configured.
config.cache_store = :memory_store if !!ENV["PROFILE"]
if !!ENV["PROFILE"]
config.cache_store = :redis_cache_store, {
driver: :hiredis,
url: ENV.fetch("OFN_REDIS_URL", "redis://localhost:6379/0"),
namespace: "cache",
expires_in: 90.minutes
}
end
config.eager_load = false

View File

@@ -42,9 +42,12 @@ Openfoodnetwork::Application.configure do
config.log_formatter = Logger::Formatter.new.tap { |f| f.datetime_format = "%Y-%m-%d %H:%M:%S" }
# Use a different cache store in production
memcached_value_max_megabytes = ENV.fetch("MEMCACHED_VALUE_MAX_MEGABYTES", 1).to_i
memcached_value_max_bytes = memcached_value_max_megabytes * 1024 * 1024
config.cache_store = :mem_cache_store, { value_max_bytes: memcached_value_max_bytes }
config.cache_store = :redis_cache_store, {
driver: :hiredis,
url: ENV.fetch("OFN_REDIS_URL", "redis://localhost:6379/0"),
namespace: "cache",
reconnect_attempts: 1
}
# Enable serving of images, stylesheets, and JavaScripts from an asset server
# config.action_controller.asset_host = "http://assets.example.com"

View File

@@ -42,9 +42,12 @@ Openfoodnetwork::Application.configure do
config.log_formatter = Logger::Formatter.new.tap { |f| f.datetime_format = "%Y-%m-%d %H:%M:%S" }
# Use a different cache store in production
memcached_value_max_megabytes = ENV.fetch("MEMCACHED_VALUE_MAX_MEGABYTES", 1).to_i
memcached_value_max_bytes = memcached_value_max_megabytes * 1024 * 1024
config.cache_store = :mem_cache_store, { value_max_bytes: memcached_value_max_bytes }
config.cache_store = :redis_cache_store, {
driver: :hiredis,
url: ENV.fetch("OFN_REDIS_URL", "redis://localhost:6379/0"),
namespace: "cache",
reconnect_attempts: 1
}
# Enable serving of images, stylesheets, and JavaScripts from an asset server
# config.action_controller.asset_host = "http://assets.example.com"