闭社主体 forked from https://github.com/tootsuite/mastodon
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

22 lines
568 B

  1. # frozen_string_literal: true
  2. if ENV['REDIS_URL'].blank?
  3. password = ENV.fetch('REDIS_PASSWORD') { '' }
  4. host = ENV.fetch('REDIS_HOST') { 'localhost' }
  5. port = ENV.fetch('REDIS_PORT') { 6379 }
  6. db = ENV.fetch('REDIS_DB') { 0 }
  7. ENV['REDIS_URL'] = "redis://#{password.blank? ? '' : ":#{password}@"}#{host}:#{port}/#{db}"
  8. end
  9. Redis.current = Redis.new(
  10. url: ENV['REDIS_URL'],
  11. driver: :hiredis
  12. )
  13. Rails.application.configure do
  14. config.cache_store = :redis_store, ENV['REDIS_URL'], {
  15. namespace: 'cache',
  16. expires_in: 10.minutes,
  17. }
  18. end