Class: IPinfo::DefaultCache
- Inherits:
-
CacheInterface
- Object
- CacheInterface
- IPinfo::DefaultCache
- Defined in:
- lib/ipinfo/cache/default_cache.rb
Instance Method Summary collapse
- #contains?(key) ⇒ Boolean
- #get(key) ⇒ Object
-
#initialize(ttl, max_size) ⇒ DefaultCache
constructor
A new instance of DefaultCache.
- #set(key, value) ⇒ Object
Constructor Details
#initialize(ttl, max_size) ⇒ DefaultCache
Returns a new instance of DefaultCache.
7 8 9 |
# File 'lib/ipinfo/cache/default_cache.rb', line 7 def initialize(ttl, max_size) @cache = LRUCache.new(:ttl => ttl, :max_size => max_size) end |
Instance Method Details
#contains?(key) ⇒ Boolean
19 20 21 |
# File 'lib/ipinfo/cache/default_cache.rb', line 19 def contains?(key) !@cache[key].nil? end |
#get(key) ⇒ Object
11 12 13 |
# File 'lib/ipinfo/cache/default_cache.rb', line 11 def get(key) @cache[key] end |
#set(key, value) ⇒ Object
15 16 17 |
# File 'lib/ipinfo/cache/default_cache.rb', line 15 def set(key, value) @cache[key] = value end |