Skip to content

Commit

Permalink
Fix Cache::NullStore with local caching for repeated reads
Browse files Browse the repository at this point in the history
  • Loading branch information
fatkodima committed Aug 1, 2023
1 parent 2e9f6a9 commit a8e88e2
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ def read_multi_entries(keys, **options)

local_entries = local_cache.read_multi_entries(keys)
local_entries.transform_values! do |payload|
deserialize_entry(payload).value
deserialize_entry(payload)&.value
end
missed_keys = keys - local_entries.keys

Expand Down
10 changes: 10 additions & 0 deletions activesupport/test/cache/stores/null_store_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -56,4 +56,14 @@ def test_local_store_strategy
end
assert_nil @cache.read("name")
end

def test_local_store_repeated_reads
@cache.with_local_cache do
@cache.read("foo")
assert_nil @cache.read("foo")

@cache.read_multi("foo", "bar")
assert_equal({ "foo" => nil, "bar" => nil }, @cache.read_multi("foo", "bar"))
end
end
end

0 comments on commit a8e88e2

Please sign in to comment.