diff options
| author | Stan Hu <stanhu@gmail.com> | 2015-12-03 00:09:10 -0800 |
|---|---|---|
| committer | Stan Hu <stanhu@gmail.com> | 2015-12-04 07:11:25 -0800 |
| commit | 32b45493b89b35b7b7d3f086e8996d1ed7b8d0f3 (patch) | |
| tree | c8451e1a8bf2d09879b23c549be3cd40c0351bf1 /app/models/ci | |
| parent | 238ca3e472a67d319521daa5aeab6455b4740cdb (diff) | |
| download | gitlab-ce-32b45493b89b35b7b7d3f086e8996d1ed7b8d0f3.tar.gz | |
Fix application settings cache not expiring after changes
cache_key is an instance method that relies on updated_at. When changes
were made, the time-dependent key was being used instead of X.application_setting.last.
Closes #3609
Diffstat (limited to 'app/models/ci')
| -rw-r--r-- | app/models/ci/application_setting.rb | 11 |
1 files changed, 4 insertions, 7 deletions
diff --git a/app/models/ci/application_setting.rb b/app/models/ci/application_setting.rb index 4e512d290ee..7f5df8ce6c4 100644 --- a/app/models/ci/application_setting.rb +++ b/app/models/ci/application_setting.rb @@ -12,17 +12,18 @@ module Ci class ApplicationSetting < ActiveRecord::Base extend Ci::Model + CACHE_KEY = 'ci_application_setting.last' after_commit do - Rails.cache.write(cache_key, self) + Rails.cache.write(CACHE_KEY, self) end def self.expire - Rails.cache.delete(cache_key) + Rails.cache.delete(CACHE_KEY) end def self.current - Rails.cache.fetch(cache_key) do + Rails.cache.fetch(CACHE_KEY) do Ci::ApplicationSetting.last end end @@ -33,9 +34,5 @@ module Ci add_pusher: Settings.gitlab_ci['add_pusher'], ) end - - def self.cache_key - 'ci_application_setting.last' - end end end |
