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.

17 lines
544 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. namespace = ENV.fetch('REDIS_NAMESPACE') { nil }
  10. cache_namespace = namespace ? namespace + '_cache' : 'cache'
  11. REDIS_CACHE_PARAMS = {
  12. expires_in: 10.minutes,
  13. namespace: cache_namespace,
  14. }.freeze