class SgtnClient::CacheUtil

Public Class Methods

clear_cache() click to toggle source
# File lib/sgtn-client/util/cache-util.rb, line 21
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 15
def self.get_cache(cache_key)
  expired, items = SgtnClient::Core::Cache.get(cache_key)
  SgtnClient.logger.debug "[CacheUtil]get cache with key #{cache_key}, expired #{expired}"
  return expired, items
end
get_cachekey(component, locale) click to toggle source
# File lib/sgtn-client/util/cache-util.rb, line 40
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
write_cache(cache_key, items) click to toggle source
# File lib/sgtn-client/util/cache-util.rb, line 26
def self.write_cache(cache_key, items)
  if items.nil?
    return nil
  end
  env = SgtnClient::Config.default_environment
  cache_expiry_period = SgtnClient::Config.configurations[env]["cache_expiry_period"]
  # expired after 24 hours
  if cache_expiry_period == nil
      cache_expiry_period = 24*60
  end
  SgtnClient.logger.debug "[CacheUtil]write cache with key #{cache_key}, cache_expiry_period #{cache_expiry_period}, itmes #{items}"
  SgtnClient::Core::Cache.put(cache_key, items, cache_expiry_period)
end