class Lucid::Shopify::CachedGet

Public Instance Methods

call(*get_args, ttl: Cache::TTL) click to toggle source

@see {Lucid::Shopify::Client#get}

@param ttl [Integer]

# File lib/lucid/shopify/cached_get.rb, line 20
def call(*get_args, ttl: Cache::TTL)
  cache.(key(*get_args), ttl: ttl) { client.get(*get_args).to_h }.freeze
end
clear(*get_args) click to toggle source

@see {Lucid::Shopify::Client#get}

@return [self]

# File lib/lucid/shopify/cached_get.rb, line 27
def clear(*get_args)
  cache.clear(key(*get_args))

  self
end

Private Instance Methods

key(credentials, path, params = {}) click to toggle source

@see {Lucid::Shopify::Client#get}

# File lib/lucid/shopify/cached_get.rb, line 34
        def key(credentials, path, params = {})
  Digest::MD5.hexdigest([
    credentials.myshopify_domain,
    path,
    params,
  ].join("\x1f")) # ASCII unit separator
end