Module: Px::Service::Client::Caching

Extended by:
ActiveSupport::Concern
Defined in:
lib/px/service/client/caching.rb,
lib/px/service/client/caching/railtie.rb,
lib/px/service/client/caching/cache_entry.rb,
lib/px/service/client/caching/log_subscriber.rb

Defined Under Namespace

Classes: CacheEntry, LogSubscriber, Railtie

Constant Summary collapse

STRATEGIES =
[
  NO_CACHE = :none,
  LAST_RESORT = :last_resort,
  FIRST_RESORT = :first_resort,
]

Instance Method Summary collapse

Instance Method Details

#cache_request(url, strategy: nil, policy_group: config.cache_default_policy_group, expires_in: config.cache_expiry, refresh_probability: 1) ⇒ Object



33
34
35
36
37
38
39
40
41
42
# File 'lib/px/service/client/caching.rb', line 33

def cache_request(url, strategy: nil, policy_group: config.cache_default_policy_group, expires_in: config.cache_expiry, refresh_probability: 1)
  case strategy
    when :last_resort
      cache_last_resort(url, policy_group: policy_group, expires_in: expires_in, refresh_probability: refresh_probability) { yield  }
    when :first_resort
      cache_first_resort(url, policy_group: policy_group, expires_in: expires_in) { yield }
    else
      no_cache { yield }
  end
end