Skip to content

Commit

Permalink
Switched to Redis cache in production (bigbluebutton#761)
Browse files Browse the repository at this point in the history
  • Loading branch information
farhatahmad authored and jfederico committed Aug 22, 2019
1 parent d3eb064 commit cfab2fd
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 1 deletion.
4 changes: 4 additions & 0 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,10 @@ group :production do

# For a better logging library in production
gem "lograge"

# Use for the cache store in production
gem 'redis'
gem 'hiredis'
end

# Ruby linting.
Expand Down
4 changes: 4 additions & 0 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,7 @@ GEM
hashie (3.6.0)
health_check (3.0.0)
railties (>= 5.0)
hiredis (0.6.3)
http_accept_language (2.1.1)
i18n (1.6.0)
concurrent-ruby (~> 1.0)
Expand Down Expand Up @@ -257,6 +258,7 @@ GEM
recaptcha (5.0.0)
json
redcarpet (3.4.0)
redis (4.1.2)
remote_syslog_logger (1.0.4)
syslog_protocol
request_store (1.4.1)
Expand Down Expand Up @@ -363,6 +365,7 @@ DEPENDENCIES
faker
font-awesome-sass (~> 5.9.0)
health_check
hiredis
http_accept_language
i18n-language-mapping (~> 0.1.0)
jbuilder (~> 2.5)
Expand All @@ -385,6 +388,7 @@ DEPENDENCIES
random_password
recaptcha
redcarpet
redis
remote_syslog_logger
rspec-rails (~> 3.7)
rubocop
Expand Down
17 changes: 16 additions & 1 deletion config/environments/production.rb
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,22 @@
config.consider_all_requests_local = false
config.action_controller.perform_caching = true

config.cache_store = :memory_store
if ENV['REDIS_URL'].present?
# Set up Redis cache store
config.cache_store = :redis_cache_store, { url: ENV['REDIS_URL'],

connect_timeout: 30, # Defaults to 20 seconds
read_timeout: 0.2, # Defaults to 1 second
write_timeout: 0.2, # Defaults to 1 second
reconnect_attempts: 1, # Defaults to 0

error_handler: lambda { |method:, returning:, exception:|
config.logger.warn "Support: Redis cache action #{method} failed and returned '#{returning}': #{exception}"
} }
else
config.cache_store = :memory_store
end

config.public_file_server.headers = {
'Cache-Control' => "public, max-age=#{1.years.to_i}"
}
Expand Down

0 comments on commit cfab2fd

Please sign in to comment.