Path: | lib/hashcache.rb |
Last Update: | Fri Mar 20 04:47:12 -0700 2009 |
A very simple cache. Works just like a Hash, but can optionally store values during the fetch process.
Example:
hc = HashCache.new hc.fetch("foo") => nil hc.fetch("foo"){:bar} # Block gets called because 'foo' is nil => :bar hc.fetch("foo"){raise "Block won't be called because 'foo' is cached"} => :bar