summaryrefslogtreecommitdiff
path: root/app/models/application_setting.rb
diff options
context:
space:
mode:
authorStan Hu <stanhu@gmail.com>2015-12-03 00:09:10 -0800
committerStan Hu <stanhu@gmail.com>2015-12-04 07:11:25 -0800
commit32b45493b89b35b7b7d3f086e8996d1ed7b8d0f3 (patch)
treec8451e1a8bf2d09879b23c549be3cd40c0351bf1 /app/models/application_setting.rb
parent238ca3e472a67d319521daa5aeab6455b4740cdb (diff)
downloadgitlab-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/application_setting.rb')
-rw-r--r--app/models/application_setting.rb12
1 files changed, 5 insertions, 7 deletions
diff --git a/app/models/application_setting.rb b/app/models/application_setting.rb
index 3df8135acf1..5ddcf3d9a0b 100644
--- a/app/models/application_setting.rb
+++ b/app/models/application_setting.rb
@@ -30,6 +30,8 @@
#
class ApplicationSetting < ActiveRecord::Base
+ CACHE_KEY = 'application_setting.last'
+
serialize :restricted_visibility_levels
serialize :import_sources
serialize :restricted_signup_domains, Array
@@ -73,21 +75,17 @@ class ApplicationSetting < ActiveRecord::Base
end
after_commit do
- Rails.cache.write(cache_key, self)
+ Rails.cache.write(CACHE_KEY, self)
end
def self.current
- Rails.cache.fetch(cache_key) 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'
+ Rails.cache.delete(CACHE_KEY)
end
def self.create_from_defaults