Class: CacheLib::FifoCache
- Inherits:
-
BasicCache
- Object
- BasicCache
- CacheLib::FifoCache
- Defined in:
- lib/cache_lib/fifo_cache.rb
Direct Known Subclasses
Instance Attribute Summary
Attributes inherited from BasicCache
Instance Method Summary collapse
-
#initialize(*args) ⇒ FifoCache
constructor
A new instance of FifoCache.
- #inspect ⇒ Object
- #limit=(args) ⇒ Object
Methods inherited from BasicCache
#clear, #each, #evict, #fetch, #get, #initialize_copy, #key?, #keys, #lookup, #raw, #size, #store, #to_a, #values
Constructor Details
#initialize(*args) ⇒ FifoCache
Returns a new instance of FifoCache.
3 4 5 6 7 8 9 10 11 12 |
# File 'lib/cache_lib/fifo_cache.rb', line 3 def initialize(*args) limit, _ = args fail ArgumentError "Cache Limit must be 1 or greater: #{limit}" if limit.nil? || limit < 1 @limit = limit @cache = UtilHash.new end |
Instance Method Details
#inspect ⇒ Object
24 25 26 27 |
# File 'lib/cache_lib/fifo_cache.rb', line 24 def inspect "#{self.class} with a limit of #{@limit} "\ "currently caching #{@cache.size} items." end |
#limit=(args) ⇒ Object
14 15 16 17 18 19 20 21 22 |
# File 'lib/cache_lib/fifo_cache.rb', line 14 def limit=(args) limit, _ = args fail ArgumentError "Cache Limit must be 1 or greater: #{limit}" if limit.nil? || limit < 1 @limit = limit resize end |