Class: Lucid::Shopify::CachedGet

Inherits:
Object
  • Object
show all
Extended by:
Dry::Initializer
Defined in:
lib/lucid/shopify/cached_get.rb

Instance Method Summary collapse

Instance Method Details

#cacheCache

Returns:



13
# File 'lib/lucid/shopify/cached_get.rb', line 13

option :cache, default: proc { Cache.new }

#call(*get_args, ttl: Cache::TTL) ⇒ Object

Parameters:

  • ttl (Integer) (defaults to: Cache::TTL)

See Also:

  • Lucid::Shopify::CachedGet.{Lucid{Lucid::Shopify{Lucid::Shopify::Client{Lucid::Shopify::Client#get}


20
21
22
# 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) ⇒ self

Returns:

  • (self)

See Also:

  • Lucid::Shopify::CachedGet.{Lucid{Lucid::Shopify{Lucid::Shopify::Client{Lucid::Shopify::Client#get}


27
28
29
30
31
# File 'lib/lucid/shopify/cached_get.rb', line 27

def clear(*get_args)
  cache.clear(key(*get_args))

  self
end

#clientLucid::Shopify::Client

Returns:

  • (Lucid::Shopify::Client)


15
# File 'lib/lucid/shopify/cached_get.rb', line 15

option :client, default: proc { Client.new }