Module: Mova::ReadStrategy::Eager
- Defined in:
- lib/mova/read_strategy/eager.rb
Overview
This strategy is more perfomant with a remote storage, where each read results in a network roundtrip. Even if your cache or database is located on localhost, reading from a socket is much more slower than reading from memory. Instead of making one read per locale/scope fallback, we get combination of all fallbacks and make one request to the storage.
Instance Method Summary collapse
Instance Method Details
#read_first(locales, key_with_scopes) ⇒ Object
17 18 19 20 21 22 |
# File 'lib/mova/read_strategy/eager.rb', line 17 def read_first(locales, key_with_scopes) locales_with_scopes = Scope.cross_join(locales, key_with_scopes) results = storage.read_multi(*locales_with_scopes) _, value = results.find { |_, value| Mova.presence(value) } value end |