Module: SgtnClient::TranslationLoader::Cache
- Defined in:
- lib/sgtn-client/loader/cache.rb
Overview
:nodoc:
Instance Method Summary collapse
- #available_bundles ⇒ Object
-
#get_bundle(component, locale) ⇒ Object
get from cache, return expired data immediately.
Instance Method Details
#available_bundles ⇒ Object
23 24 25 26 27 28 29 30 31 32 33 |
# File 'lib/sgtn-client/loader/cache.rb', line 23 def available_bundles SgtnClient.logger.debug { "[#{__FILE__}][#{__callee__}]" } cache_item = CacheUtil.get_cache(CONSTS::AVAILABLE_BUNDLES_KEY) if cache_item super(sync: false) if CacheUtil.is_expired(cache_item) cache_item[:items] else super end end |
#get_bundle(component, locale) ⇒ Object
get from cache, return expired data immediately
10 11 12 13 14 15 16 17 18 19 20 21 |
# File 'lib/sgtn-client/loader/cache.rb', line 10 def get_bundle(component, locale) SgtnClient.logger.debug { "[#{__FILE__}][#{__callee__}] component=#{component}, locale=#{locale}" } key = Common::BundleID.new(component, locale) cache_item = CacheUtil.get_cache(key) if cache_item load_bundle(component, locale, sync: false) if CacheUtil.is_expired(cache_item) cache_item[:items] else load_bundle(component, locale) end end |