Try and use cache for application settings even when the db is not connected

This commit is contained in:
DJ Mountney 2016-05-29 12:53:30 -07:00
parent 7d57b11093
commit c8eb1dccab
2 changed files with 6 additions and 2 deletions

View file

@ -98,6 +98,10 @@ class ApplicationSetting < ActiveRecord::Base
Rails.cache.delete(CACHE_KEY)
end
def self.cached
Rails.cache.fetch(CACHE_KEY)
end
def self.create_from_defaults
create(
default_projects_limit: Settings.gitlab['default_projects_limit'],

View file

@ -9,9 +9,9 @@ module Gitlab
end
def ensure_application_settings!
settings = nil
settings = ::ApplicationSetting.cached
if connect_to_db?
if !settings && connect_to_db?
settings = ::ApplicationSetting.current
settings ||= ::ApplicationSetting.create_from_defaults unless ActiveRecord::Migrator.needs_migration?
end