Class: Pinky::LruCache
- Inherits:
-
LinkedHashMap
- Object
- LinkedHashMap
- Pinky::LruCache
- Defined in:
- lib/pinky/lru_cache.rb
Instance Attribute Summary collapse
-
#maxEntries ⇒ Object
readonly
Returns the value of attribute maxEntries.
Instance Method Summary collapse
-
#initialize(maxEntries) ⇒ LruCache
constructor
A new instance of LruCache.
- #removeEldestEntry(map) ⇒ Object
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
#maxEntries ⇒ Object (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 |