Skip to content

Commit

Permalink
Merge pull request #29083 from eugeneius/local_cache_unless_exist
Browse files Browse the repository at this point in the history
Don't cache locally if unless_exist was passed
  • Loading branch information
eileencodes committed May 15, 2017
2 parents d48008f + db9ae5f commit 5bfb287
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 1 deletion.
Expand Up @@ -115,7 +115,12 @@ def read_entry(key, options)
end end


def write_entry(key, entry, options) 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 super
end end


Expand Down
8 changes: 8 additions & 0 deletions activesupport/test/caching_test.rb
Expand Up @@ -708,6 +708,14 @@ def test_local_cache_of_write_nil
end end
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 def test_local_cache_of_delete
@cache.with_local_cache do @cache.with_local_cache do
@cache.write("foo", "bar") @cache.write("foo", "bar")
Expand Down

0 comments on commit 5bfb287

Please sign in to comment.