Class: Miteru::Cache
Instance Attribute Summary collapse
Instance Method Summary
collapse
Methods inherited from Service
#call, call, #result, result
Constructor Details
#initialize(url) ⇒ Cache
Returns a new instance of Cache.
11
12
13
14
|
# File 'lib/miteru/cache.rb', line 11
def initialize(url)
super()
@url = url
end
|
Instance Attribute Details
#url ⇒ String
6
7
8
|
# File 'lib/miteru/cache.rb', line 6
def url
@url
end
|
Instance Method Details
#cached?(key) ⇒ Boolean
30
31
32
33
34
|
# File 'lib/miteru/cache.rb', line 30
def cached?(key)
value = redis.exists?("#{cache_prefix}:#{key}")
logger.info("Cache:#{key} found.") if verbose?
value
end
|
#set(key, value, ex:) ⇒ Object
21
22
23
24
25
|
# File 'lib/miteru/cache.rb', line 21
def set(key, value, ex:)
value = redis.set("#{cache_prefix}:#{key}", value, ex:)
logger.info("Cache:#{key} is set.") if verbose?
value
end
|