mirror of
https://github.com/wahyd4/gitlabhq.git
synced 2026-08-09 20:56:08 +10:00
Try and use cache for application settings even when the db is not connected
This commit is contained in:
@@ -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'],
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user