diff options
author | Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com> | 2015-11-30 12:23:25 +0300 |
---|---|---|
committer | Robert Speicher <rspeicher@gmail.com> | 2015-11-30 19:54:44 +0300 |
commit | 3b9a9109388f02e5ed127e24d32838a9cd761b59 (patch) | |
tree | 1a336fa34e4a38265b3a2526c3562072ba82a2c9 /app | |
parent | 0bbf7563a66490b614ee035b9b4fe75a5aba5e08 (diff) |
Merge branch 'expire-application-settings-startup' of https://gitlab.com/stanhu/gitlab-ce
Diffstat (limited to 'app')
-rw-r--r-- | app/models/application_setting.rb | 12 | ||||
-rw-r--r-- | app/models/ci/application_setting.rb | 12 |
2 files changed, 20 insertions, 4 deletions
diff --git a/app/models/application_setting.rb b/app/models/application_setting.rb index b2d5fe1558f..3df8135acf1 100644 --- a/app/models/application_setting.rb +++ b/app/models/application_setting.rb @@ -73,15 +73,23 @@ class ApplicationSetting < ActiveRecord::Base end after_commit do - Rails.cache.write('application_setting.last', self) + Rails.cache.write(cache_key, self) end def self.current - Rails.cache.fetch('application_setting.last') do + Rails.cache.fetch(cache_key) do ApplicationSetting.last end end + def self.expire + Rails.cache.delete(cache_key) + end + + def self.cache_key + 'application_setting.last' + end + def self.create_from_defaults create( default_projects_limit: Settings.gitlab['default_projects_limit'], diff --git a/app/models/ci/application_setting.rb b/app/models/ci/application_setting.rb index 1307fa0b472..4e512d290ee 100644 --- a/app/models/ci/application_setting.rb +++ b/app/models/ci/application_setting.rb @@ -14,11 +14,15 @@ module Ci extend Ci::Model after_commit do - Rails.cache.write('ci_application_setting.last', self) + Rails.cache.write(cache_key, self) + end + + def self.expire + Rails.cache.delete(cache_key) end def self.current - Rails.cache.fetch('ci_application_setting.last') do + Rails.cache.fetch(cache_key) do Ci::ApplicationSetting.last end end @@ -29,5 +33,9 @@ module Ci add_pusher: Settings.gitlab_ci['add_pusher'], ) end + + def self.cache_key + 'ci_application_setting.last' + end end end |