class SgtnClient::CacheUtil
Public Class Methods
clear_cache()
click to toggle source
# File lib/sgtn-client/util/cache-util.rb, line 15 def self.clear_cache SgtnClient::Core::Cache.clear SgtnClient.logger.debug '[CacheUtil]clear cache' end
get_cache(cache_key)
click to toggle source
# File lib/sgtn-client/util/cache-util.rb, line 10 def self.get_cache(cache_key) SgtnClient.logger.debug "[CacheUtil]get cache with key #{cache_key}" SgtnClient::Core::Cache.get(cache_key) end
get_cachekey(component, locale)
click to toggle source
# File lib/sgtn-client/util/cache-util.rb, line 31 def self.get_cachekey(component, locale) env = SgtnClient::Config.default_environment product_name = SgtnClient::Config.configurations[env]['product_name'] version = SgtnClient::Config.configurations[env]['version'].to_s product_name + '_' + version + '_' + component + '_' + locale end
is_expired(cache_item)
click to toggle source
# File lib/sgtn-client/util/cache-util.rb, line 38 def self.is_expired(cache_item) cache_item[:expiry] < Time.now end
write_cache(cache_key, items)
click to toggle source
# File lib/sgtn-client/util/cache-util.rb, line 20 def self.write_cache(cache_key, items) return nil if items.nil? || items.empty? env = SgtnClient::Config.default_environment cache_expiry_period = SgtnClient::Config.configurations[env]['cache_expiry_period'] # expired after 24 hours cache_expiry_period = 24 * 60 if cache_expiry_period.nil? SgtnClient.logger.debug "[CacheUtil]write cache with key #{cache_key}, cache_expiry_period #{cache_expiry_period}" SgtnClient::Core::Cache.put(cache_key, items, cache_expiry_period) end