Class: Csv2Psql::Cache

Inherits:
Object
  • Object
show all
Defined in:
lib/csv2psql/cache/cache.rb

Overview

Last Recently Used cache implementation

Instance Attribute Summary collapse

Instance Method Summary collapse

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_sizeObject

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