Class: ShopifyClient::Cache::RedisStore

Inherits:
Store
  • Object
show all
Defined in:
lib/shopify-client/cache/redis_store.rb

Instance Method Summary collapse

Methods inherited from Store

#call, #initialize

Constructor Details

This class inherits a constructor from ShopifyClient::Cache::Store

Instance Method Details

#clear(key) ⇒ Object

See Also:



23
24
25
# File 'lib/shopify-client/cache/redis_store.rb', line 23

def clear(key)
  Redis.current.del(key)
end

#get(key) ⇒ Object

See Also:

  • Store#get


7
8
9
10
11
# File 'lib/shopify-client/cache/redis_store.rb', line 7

def get(key)
  value = Redis.current.get(key)

  @decode.(value) unless value.nil?
end

#set(key, value, ttl: ShopifyClient.config.cache_ttl) ⇒ Object

See Also:



14
15
16
17
18
19
20
# File 'lib/shopify-client/cache/redis_store.rb', line 14

def set(key, value, ttl: ShopifyClient.config.cache_ttl)
  Redis.current.set(key, @encode.(value))

  if ttl > 0
    Redis.current.expire(key, ttl)
  end
end