Improved performance by checking in memory Cache TTL with integers instead of TimeZone objects (issue #2374).
This commit is contained in:
parent
2537dbeceb
commit
0711953beb
1 changed files with 3 additions and 3 deletions
|
@ -127,7 +127,7 @@ reload config settings
|
||||||
end
|
end
|
||||||
|
|
||||||
@@change_id = Cache.get('Setting::ChangeId') # rubocop:disable Style/ClassVars
|
@@change_id = Cache.get('Setting::ChangeId') # rubocop:disable Style/ClassVars
|
||||||
@@lookup_at = Time.zone.now # rubocop:disable Style/ClassVars
|
@@lookup_at = Time.now.to_i # rubocop:disable Style/ClassVars
|
||||||
true
|
true
|
||||||
end
|
end
|
||||||
private_class_method :load
|
private_class_method :load
|
||||||
|
@ -158,14 +158,14 @@ reload config settings
|
||||||
|
|
||||||
# check if cache is still valid
|
# check if cache is still valid
|
||||||
def self.cache_valid?
|
def self.cache_valid?
|
||||||
if @@lookup_at && @@lookup_at > Time.zone.now - @@lookup_timeout
|
if @@lookup_at && @@lookup_at > Time.now.to_i - @@lookup_timeout
|
||||||
#logger.debug "Setting.cache_valid?: cache_id has been set within last #{@@lookup_timeout} seconds"
|
#logger.debug "Setting.cache_valid?: cache_id has been set within last #{@@lookup_timeout} seconds"
|
||||||
return true
|
return true
|
||||||
end
|
end
|
||||||
|
|
||||||
change_id = Cache.get('Setting::ChangeId')
|
change_id = Cache.get('Setting::ChangeId')
|
||||||
if @@change_id && change_id == @@change_id
|
if @@change_id && change_id == @@change_id
|
||||||
@@lookup_at = Time.zone.now # rubocop:disable Style/ClassVars
|
@@lookup_at = Time.now.to_i # rubocop:disable Style/ClassVars
|
||||||
#logger.debug "Setting.cache_valid?: cache still valid, #{@@change_id}/#{change_id}"
|
#logger.debug "Setting.cache_valid?: cache still valid, #{@@change_id}/#{change_id}"
|
||||||
return true
|
return true
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in a new issue