Class: Pinky::LruCache

Inherits:
LinkedHashMap
  • Object
show all
Defined in:
lib/pinky/lru_cache.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(maxEntries) ⇒ LruCache

Returns a new instance of LruCache.



8
9
10
11
# File 'lib/pinky/lru_cache.rb', line 8

def initialize(maxEntries)
  super(maxEntries + 1, 1, true)
  @maxEntries = maxEntries;
end

Instance Attribute Details

#maxEntriesObject (readonly)

Returns the value of attribute maxEntries.



6
7
8
# File 'lib/pinky/lru_cache.rb', line 6

def maxEntries
  @maxEntries
end

Instance Method Details

#removeEldestEntry(map) ⇒ Object



13
14
15
# File 'lib/pinky/lru_cache.rb', line 13

def removeEldestEntry(map)
  return true if size > @maxEntries
end