From 0711953beb865b33adfb854dde1805ee0ad7d0e4 Mon Sep 17 00:00:00 2001 From: Thorsten Eckel Date: Mon, 26 Nov 2018 15:51:23 +0100 Subject: [PATCH] Improved performance by checking in memory Cache TTL with integers instead of TimeZone objects (issue #2374). --- app/models/setting.rb | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/app/models/setting.rb b/app/models/setting.rb index 6824f8654..fa3267a84 100644 --- a/app/models/setting.rb +++ b/app/models/setting.rb @@ -127,7 +127,7 @@ reload config settings end @@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 end private_class_method :load @@ -158,14 +158,14 @@ reload config settings # check if cache is still 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" return true end change_id = Cache.get('Setting::ChangeId') 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}" return true end