Sha256: 9a40ca3a27bd3955bcd8c03bda826839c47cd66a9d33b51eeb742930519b6bb8
Contents?: true
Size: 821 Bytes
Versions: 2
Compression:
Stored size: 821 Bytes
Contents
$:.unshift(File.dirname(__FILE__)) Dir.glob("#{File.dirname(__FILE__)}/../ext/*.rb").each { |file| require file } require 'monitored_hash' require 'simple_hash_eviction' # 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. class HashCache attr_reader :hash def initialize(opts={}) @eviction_policy = SimpleHashEviction.new(opts[:n]) @hash = MonitoredHash.new @hash.add_observer(@eviction_policy) end def n @eviction_policy.n end def method_missing(sym, *args, &block) @hash.send(sym, *args, &block) end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
davidrichards-repositories-0.0.4 | lib/repositories/hash_cache.rb |
davidrichards-repositories-0.0.5 | lib/repositories/hash_cache.rb |