lib/object/cache.rb in object-cache-0.1.1 vs lib/object/cache.rb in object-cache-0.1.2
- old
+ new
@@ -42,15 +42,15 @@
# bad:
#
# Cache.new { item } # item is only stored once, and then always
# # retrieved, even if it is a different item
#
- def new(key = nil, ttl: default_ttl, key_prefix: default_key_prefix)
+ def new(key = nil, ttl: default_ttl, key_prefix: default_key_prefix, &block)
return yield unless replica
begin
- key = build_key(key, key_prefix, Proc.new)
+ key = build_key(key, key_prefix, block)
if (cached_value = replica.get(key)).nil?
yield.tap do |value|
begin
update_cache(key, value, ttl: ttl)
@@ -72,10 +72,10 @@
end
end
end
def include?(key)
- replica.exists(key)
+ replica.exists?(key)
rescue
false
end
def delete(key)