[#350] Refactor: extract method
This commit is contained in:
parent
c51a32ac23
commit
e4fac8d40f
|
@ -148,11 +148,16 @@ class Setting < ActiveRecord::Base
|
||||||
cache_cleared_on = Rails.cache.read('chiliproject/setting-cleared_on')
|
cache_cleared_on = Rails.cache.read('chiliproject/setting-cleared_on')
|
||||||
cache_cleared_on = cache_cleared_on ? Marshal.load(cache_cleared_on) : Time.now
|
cache_cleared_on = cache_cleared_on ? Marshal.load(cache_cleared_on) : Time.now
|
||||||
if settings_updated_on && cache_cleared_on <= settings_updated_on
|
if settings_updated_on && cache_cleared_on <= settings_updated_on
|
||||||
Rails.cache.delete_matched( /^chiliproject\/setting\/.+$/ )
|
clear_cache
|
||||||
Rails.cache.write('chiliproject/setting-cleared_on', Marshal.dump(Time.now))
|
|
||||||
logger.info 'Settings cache cleared.' if logger
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
# Clears all of the Setting caches
|
||||||
|
def self.clear_cache
|
||||||
|
Rails.cache.delete_matched( /^chiliproject\/setting\/.+$/ )
|
||||||
|
Rails.cache.write('chiliproject/setting-cleared_on', Marshal.dump(Time.now))
|
||||||
|
logger.info 'Settings cache cleared.' if logger
|
||||||
|
end
|
||||||
|
|
||||||
private
|
private
|
||||||
# Returns the Setting instance for the setting named name
|
# Returns the Setting instance for the setting named name
|
||||||
|
|
Loading…
Reference in New Issue