Skip to content

Commit a8e88e2

Browse files
committed
Fix Cache::NullStore with local caching for repeated reads
1 parent 2e9f6a9 commit a8e88e2

File tree

2 files changed

+11
-1
lines changed

2 files changed

+11
-1
lines changed

‎activesupport/lib/active_support/cache/strategy/local_cache.rb‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,7 @@ def read_multi_entries(keys, **options)
124124

125125
local_entries=local_cache.read_multi_entries(keys)
126126
local_entries.transform_values!do |payload|
127-
deserialize_entry(payload).value
127+
deserialize_entry(payload)&.value
128128
end
129129
missed_keys=keys - local_entries.keys
130130

‎activesupport/test/cache/stores/null_store_test.rb‎

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,4 +56,14 @@ def test_local_store_strategy
5656
end
5757
assert_nil@cache.read("name")
5858
end
59+
60+
deftest_local_store_repeated_reads
61+
@cache.with_local_cachedo
62+
@cache.read("foo")
63+
assert_nil@cache.read("foo")
64+
65+
@cache.read_multi("foo","bar")
66+
assert_equal({"foo"=>nil,"bar"=>nil},@cache.read_multi("foo","bar"))
67+
end
68+
end
5969
end

0 commit comments

Comments
(0)