Commit 37465f44 authored by Dmitriy Zaporozhets's avatar Dmitriy Zaporozhets

Merge pull request #9825 from huacnlee/cache-application-setting

Add caching for ApplicationSetting, Ci::ApplicationSetting.
parents b72cbd8d 2e4a673c
...@@ -68,9 +68,15 @@ class ApplicationSetting < ActiveRecord::Base ...@@ -68,9 +68,15 @@ class ApplicationSetting < ActiveRecord::Base
end end
end end
after_commit do
Rails.cache.write('application_setting.last', self)
end
def self.current def self.current
Rails.cache.fetch('application_setting.last') do
ApplicationSetting.last ApplicationSetting.last
end end
end
def self.create_from_defaults def self.create_from_defaults
create( create(
......
...@@ -13,9 +13,15 @@ module Ci ...@@ -13,9 +13,15 @@ module Ci
class ApplicationSetting < ActiveRecord::Base class ApplicationSetting < ActiveRecord::Base
extend Ci::Model extend Ci::Model
after_commit do
Rails.cache.write('ci_application_setting.last', self)
end
def self.current def self.current
Rails.cache.fetch('ci_application_setting.last') do
Ci::ApplicationSetting.last Ci::ApplicationSetting.last
end end
end
def self.create_from_defaults def self.create_from_defaults
create( create(
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment