lib/zache.rb in zache-0.6.0 vs lib/zache.rb in zache-0.7.0

- old
+ new

@@ -39,10 +39,14 @@ class Zache # Fake implementation that doesn't cache anything, but behaves like it # does. It implements all methods of the original class, but doesn't do # any caching. This is very useful for testing. class Fake + def size + 1 + end + def get(*) yield end def exists?(*) @@ -72,9 +76,14 @@ def initialize(sync: true, dirty: false) @hash = {} @sync = sync @dirty = dirty @mutex = Mutex.new + end + + # Total number of keys currently in cache. + def size + @hash.size end # Gets the value from the cache by the provided key. If the value is not # found in the cache, it will be calculated via the provided block. If # the block is not given, an exception will be raised. The lifetime