Class: Csv2Psql::Cache
- Inherits:
-
Object
- Object
- Csv2Psql::Cache
- Defined in:
- lib/csv2psql/cache/cache.rb
Overview
Last Recently Used cache implementation
Instance Attribute Summary collapse
-
#max_size ⇒ Object
Returns the value of attribute max_size.
Instance Method Summary collapse
- #get(key, &block) ⇒ Object
-
#initialize(max_size = 1000) ⇒ Cache
constructor
A new instance of Cache.
- #put(key, value) ⇒ Object
Constructor Details
#initialize(max_size = 1000) ⇒ Cache
Returns a new instance of Cache.
10 11 12 |
# File 'lib/csv2psql/cache/cache.rb', line 10 def initialize(max_size = 1000) @cache = ::Cache::LRU.new(max_elements: max_size) end |
Instance Attribute Details
#max_size ⇒ Object
Returns the value of attribute max_size.
8 9 10 |
# File 'lib/csv2psql/cache/cache.rb', line 8 def max_size @max_size end |
Instance Method Details
#get(key, &block) ⇒ Object
18 19 20 |
# File 'lib/csv2psql/cache/cache.rb', line 18 def get(key, &block) @cache.get(key, &block) end |
#put(key, value) ⇒ Object
14 15 16 |
# File 'lib/csv2psql/cache/cache.rb', line 14 def put(key, value) @cache.put(key, value) end |