Class: I18n::Backend::CachedKeyValueStore
- Inherits:
-
KeyValue
- Object
- KeyValue
- I18n::Backend::CachedKeyValueStore
- Includes:
- Memoize
- Defined in:
- lib/i18n/backend/cached_key_value_store.rb
Constant Summary collapse
- KEY_PREFIX =
'i18n:locale_version:'
Instance Method Summary collapse
- #current_version(locale) ⇒ Object
- #ensure_freshness!(locale) ⇒ Object
- #last_version ⇒ Object
- #store_translations(locale, data, options = {}) ⇒ Object
- #update_version!(locale) ⇒ Object
Instance Method Details
#current_version(locale) ⇒ Object
30 31 32 |
# File 'lib/i18n/backend/cached_key_value_store.rb', line 30 def current_version(locale) @store["#{KEY_PREFIX}#{locale}"] end |
#ensure_freshness!(locale) ⇒ Object
13 14 15 16 17 18 19 20 |
# File 'lib/i18n/backend/cached_key_value_store.rb', line 13 def ensure_freshness!(locale) current = current_version locale if last_version[locale] != current reset_memoizations! locale last_version[locale] = current end end |
#last_version ⇒ Object
22 23 24 |
# File 'lib/i18n/backend/cached_key_value_store.rb', line 22 def last_version @last_version ||= {} end |
#store_translations(locale, data, options = {}) ⇒ Object
8 9 10 11 |
# File 'lib/i18n/backend/cached_key_value_store.rb', line 8 def store_translations(locale, data, = {}) update_version! locale super end |
#update_version!(locale) ⇒ Object
26 27 28 |
# File 'lib/i18n/backend/cached_key_value_store.rb', line 26 def update_version!(locale) @store["#{KEY_PREFIX}#{locale}"] = Time.now.to_i end |