Class: SgtnClient::CacheUtil

Inherits:
Object
  • Object
show all
Defined in:
lib/sgtn-client/util/cache-util.rb

Class Method Summary collapse

Class Method Details

.get_cache(cache_key) ⇒ Object



12
13
14
15
# File 'lib/sgtn-client/util/cache-util.rb', line 12

def self.get_cache(cache_key)
  items = SgtnClient::Core::Cache.get(cache_key)
  return items
end

.get_cachekey(component, locale) ⇒ Object



27
28
29
30
31
32
# File 'lib/sgtn-client/util/cache-util.rb', line 27

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
  return product_name + "_" + version + "_" + component + "_" + locale
end

.write_cache(cache_key, items) ⇒ Object



17
18
19
20
21
22
23
24
25
# File 'lib/sgtn-client/util/cache-util.rb', line 17

def self.write_cache(cache_key, items)
  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::Core::Cache.put(cache_key, items, cache_expiry_period)
end