Class: HashCache
- Inherits:
-
Object
- Object
- HashCache
- Defined in:
- lib/repositories/hash_cache.rb
Overview
This is a FIFO Hash. Why do I want a FIFO hash? For eroding configurations, of course!!! Just kidding. This is to keep large dictionaries limited to often-used values. When all the values can be calculated anyway, but a dictionary runs the risk of growing too large, this keeps the dictionary in check.
Instance Attribute Summary collapse
-
#hash ⇒ Object
readonly
Returns the value of attribute hash.
Instance Method Summary collapse
-
#initialize(opts = {}) ⇒ HashCache
constructor
A new instance of HashCache.
- #method_missing(sym, *args, &block) ⇒ Object
Constructor Details
#initialize(opts = {}) ⇒ HashCache
Returns a new instance of HashCache.
16 17 18 19 20 |
# File 'lib/repositories/hash_cache.rb', line 16 def initialize(opts={}) eviction_policy = SimpleHashEviction.new(opts[:n]) @hash = MonitoredHash.new @hash.add_observer(eviction_policy) end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(sym, *args, &block) ⇒ Object
22 23 24 |
# File 'lib/repositories/hash_cache.rb', line 22 def method_missing(sym, *args, &block) @hash.send(sym, *args, &block) end |
Instance Attribute Details
#hash ⇒ Object (readonly)
Returns the value of attribute hash.
14 15 16 |
# File 'lib/repositories/hash_cache.rb', line 14 def hash @hash end |