diff options
author | Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com> | 2015-11-13 12:15:52 +0300 |
---|---|---|
committer | Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com> | 2015-11-13 12:15:52 +0300 |
commit | 37465f44b40df9709507fda7a022f1907b23d53f (patch) | |
tree | dd23e4033de873650504a1b5bb44b79c917aa85f | |
parent | b72cbd8d7da4a43261af5832a8b381688cf58f65 (diff) | |
parent | 2e4a673cbc1a43532e8aa096e4ab5ca034b804f7 (diff) |
Merge pull request #9825 from huacnlee/cache-application-setting
Add caching for ApplicationSetting, Ci::ApplicationSetting.
-rw-r--r-- | app/models/application_setting.rb | 8 | ||||
-rw-r--r-- | app/models/ci/application_setting.rb | 10 |
2 files changed, 15 insertions, 3 deletions
diff --git a/app/models/application_setting.rb b/app/models/application_setting.rb index fa7cf2464ad..6d2711268e1 100644 --- a/app/models/application_setting.rb +++ b/app/models/application_setting.rb @@ -68,8 +68,14 @@ class ApplicationSetting < ActiveRecord::Base end end + after_commit do + Rails.cache.write('application_setting.last', self) + end + def self.current - ApplicationSetting.last + Rails.cache.fetch('application_setting.last') do + ApplicationSetting.last + end end def self.create_from_defaults diff --git a/app/models/ci/application_setting.rb b/app/models/ci/application_setting.rb index 0cf496f7d81..4ab3e2dcbb3 100644 --- a/app/models/ci/application_setting.rb +++ b/app/models/ci/application_setting.rb @@ -12,9 +12,15 @@ module Ci class ApplicationSetting < ActiveRecord::Base extend Ci::Model - + + after_commit do + Rails.cache.write('ci_application_setting.last', self) + end + def self.current - Ci::ApplicationSetting.last + Rails.cache.fetch('ci_application_setting.last') do + Ci::ApplicationSetting.last + end end def self.create_from_defaults |