Class: ShopifyClient::Cache::ThreadLocalStore
- Inherits:
-
Store
- Object
- Store
- ShopifyClient::Cache::ThreadLocalStore
show all
- Defined in:
- lib/shopify-client/cache/thread_local_store.rb
Instance Method Summary
collapse
Methods inherited from Store
#call, #initialize
Instance Method Details
#clear(key) ⇒ Object
25
26
27
28
|
# File 'lib/shopify-client/cache/thread_local_store.rb', line 25
def clear(key)
Thread.current[key] = nil
Thread.current[build_expiry_key(key)] = nil
end
|
#get(key) ⇒ Object
7
8
9
10
11
12
13
|
# File 'lib/shopify-client/cache/thread_local_store.rb', line 7
def get(key)
return nil if expired?(key)
value = Thread.current[key]
@decode.(value) unless value.nil?
end
|
#set(key, value, ttl: ShopifyClient.config.cache_ttl) ⇒ Object
16
17
18
19
20
21
22
|
# File 'lib/shopify-client/cache/thread_local_store.rb', line 16
def set(key, value, ttl: ShopifyClient.config.cache_ttl)
Thread.current[key] = @encode.(value)
if ttl > 0
Thread.current[build_expiry_key(key)] = Time.now + ttl
end
end
|