class GoogleDistanceMatrix::ClientCache
Cached client, which takes care of caching data from Google API
Attributes
cache[R]
client[R]
Public Class Methods
key(url, config)
click to toggle source
Returns a cache key for given URL
@return String
# File lib/google_distance_matrix/client_cache.rb, line 11 def self.key(url, config) config.cache_key_transform.call url end
new(client, cache)
click to toggle source
# File lib/google_distance_matrix/client_cache.rb, line 15 def initialize(client, cache) @client = client @cache = cache end
Public Instance Methods
get(url, options = {})
click to toggle source
# File lib/google_distance_matrix/client_cache.rb, line 20 def get(url, options = {}) cache.fetch self.class.key(url, options.fetch(:configuration)) do client.get url, **options end end