Permalink
Browse files

Merge pull request #29083 from eugeneius/local_cache_unless_exist

Don't cache locally if unless_exist was passed
  • Loading branch information...
eileencodes committed May 15, 2017
2 parents d48008f + db9ae5f commit 5bfb2875e9287c75f91e89f5e50654e5fbaa5855
@@ -115,7 +115,12 @@ def read_entry(key, options)
end
def write_entry(key, entry, options)
local_cache.write_entry(key, entry, options) if local_cache
if options[:unless_exist]
local_cache.delete_entry(key, options) if local_cache
else
local_cache.write_entry(key, entry, options) if local_cache
end
super
end
@@ -708,6 +708,14 @@ def test_local_cache_of_write_nil
end
end
def test_local_cache_of_write_with_unless_exist
@cache.with_local_cache do
@cache.write("foo", "bar")
@cache.write("foo", "baz", unless_exist: true)
assert_equal @peek.read("foo"), @cache.read("foo")
end
end
def test_local_cache_of_delete
@cache.with_local_cache do
@cache.write("foo", "bar")

0 comments on commit 5bfb287

Please sign in to comment.