1
0
Fork 0
mirror of https://github.com/rails/rails.git synced 2022-11-09 12:12:34 -05:00

Merge pull request #44366 from avalanche123/patch-1

Fix deserialization in LocalCache#read_multi_entries
This commit is contained in:
Jean Boussier 2022-02-12 10:43:39 +01:00 committed by GitHub
commit d4ef8c26a5
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 12 additions and 0 deletions

View file

@ -123,6 +123,9 @@ module ActiveSupport
return super unless local_cache
local_entries = local_cache.read_multi_entries(keys)
local_entries.transform_values! do |payload|
deserialize_entry(payload).value
end
missed_keys = keys - local_entries.keys
if missed_keys.any?

View file

@ -286,4 +286,13 @@ module LocalCacheBehavior
assert_equal false, @cache.read(key)
end
end
def test_local_cache_should_deserialize_entries_on_multi_get
keys = Array.new(5) { SecureRandom.uuid }
values = keys.index_with(true)
@cache.with_local_cache do
assert @cache.write_multi(values)
assert_equal values, @cache.read_multi(*keys)
end
end
end