Class: SgtnClient::CacheUtil
- Inherits:
-
Object
- Object
- SgtnClient::CacheUtil
- Defined in:
- lib/sgtn-client/util/cache-util.rb
Class Method Summary collapse
- .clear_cache ⇒ Object
- .get_cache(cache_key) ⇒ Object
- .get_cachekey(component, locale) ⇒ Object
- .is_expired(cache_item) ⇒ Object
- .write_cache(cache_key, items) ⇒ Object
Class Method Details
.clear_cache ⇒ Object
14 15 16 |
# File 'lib/sgtn-client/util/cache-util.rb', line 14 def self.clear_cache SgtnClient::Core::Cache.clear end |
.get_cache(cache_key) ⇒ Object
10 11 12 |
# File 'lib/sgtn-client/util/cache-util.rb', line 10 def self.get_cache(cache_key) SgtnClient::Core::Cache.get(cache_key) end |
.get_cachekey(component, locale) ⇒ Object
28 29 30 31 32 33 |
# File 'lib/sgtn-client/util/cache-util.rb', line 28 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) ⇒ Object
35 36 37 |
# File 'lib/sgtn-client/util/cache-util.rb', line 35 def self.is_expired(cache_item) cache_item[:expiry] < Time.now end |
.write_cache(cache_key, items) ⇒ Object
18 19 20 21 22 23 24 25 26 |
# File 'lib/sgtn-client/util/cache-util.rb', line 18 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::Core::Cache.put(cache_key, items, cache_expiry_period) end |