Skip to content

Commit

Permalink
conf: add redis
Browse files Browse the repository at this point in the history
  • Loading branch information
LeSim committed Jul 18, 2023
1 parent 361f6e6 commit c90789b
Show file tree
Hide file tree
Showing 5 changed files with 31 additions and 2 deletions.
1 change: 1 addition & 0 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@ gem 'rack-attack'
gem 'rails-i18n' # Locales par défaut
gem 'rake-progressbar', require: false
gem 'redcarpet'
gem 'redis'
gem 'rexml' # add missing gem due to ruby3 (https://github.com/Shopify/bootsnap/issues/325)
gem 'rqrcode'
gem 'saml_idp'
Expand Down
6 changes: 6 additions & 0 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -171,6 +171,7 @@ GEM
coercible (1.0.0)
descendants_tracker (~> 0.0.1)
concurrent-ruby (1.2.2)
connection_pool (2.4.1)
content_disposition (1.0.0)
crack (0.4.5)
rexml
Expand Down Expand Up @@ -561,6 +562,10 @@ GEM
rb-inotify (0.10.1)
ffi (~> 1.0)
redcarpet (3.6.0)
redis (5.0.6)
redis-client (>= 0.9.0)
redis-client (0.14.1)
connection_pool
regexp_parser (2.8.1)
request_store (1.5.0)
rack (>= 1.4)
Expand Down Expand Up @@ -893,6 +898,7 @@ DEPENDENCIES
rails-i18n
rake-progressbar
redcarpet
redis
rexml
rqrcode
rspec-rails
Expand Down
5 changes: 5 additions & 0 deletions config/env.example.optional
Original file line number Diff line number Diff line change
Expand Up @@ -207,3 +207,8 @@ COJO_JWT_RSA_PRIVATE_KEY=""
COJO_JWT_ISS=""

API_COJO_URL=""

# Use redis as primary rails cache store, file system otherwise
REDIS_CACHE_URL=""
REDIS_CACHE_SSL="enabled"
REDIS_CACHE_SSL_VERIFY_NONE="enabled"
6 changes: 5 additions & 1 deletion config/environments/development.rb
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,11 @@
config.action_controller.perform_caching = true
config.action_controller.enable_fragment_cache_logging = true

config.cache_store = :memory_store
if ENV['REDIS_CACHE_URL'].present?
config.cache_store = :redis_cache_store, { url: ENV['REDIS_CACHE_URL'] }
else
config.cache_store = :memory_store
end
config.public_file_server.headers = {
'Cache-Control' => "public, max-age=#{2.days.to_i}"
}
Expand Down
15 changes: 14 additions & 1 deletion config/environments/production.rb
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,20 @@
# config.logger = ActiveSupport::TaggedLogging.new(SyslogLogger.new)

# Use a different cache store in production.
# config.cache_store = :mem_cache_store
if ENV['REDIS_CACHE_URL'].present?
redis_options = { url: ENV['REDIS_CACHE_URL'] }
redis_options[:ssl] = (ENV['REDIS_CACHE_SSL'] == 'enabled')
if ENV['REDIS_CACHE_SSL_VERIFY_NONE'] == 'enabled'
redis_options[:ssl_params] = { verify_mode: OpenSSL::SSL::VERIFY_NONE }
end

redis_options[:error_handler] = -> (method:, returning:, exception:) {
Raven.capture_exception exception, level: 'warning',
tags: { method: method, returning: returning }
}

config.cache_store = :redis_cache_store, redis_options
end

# Use a real queuing backend for Active Job (and separate queues per environment).
config.active_job.queue_adapter = :delayed_job
Expand Down

0 comments on commit c90789b

Please sign in to comment.