mirror of
https://github.com/rails/rails.git
synced 2022-11-09 12:12:34 -05:00
Fix Cache read_multi
with local_cache return values.
It should returns raw value, not instance of `ActiveSupport::Cache::Entry`.
This commit is contained in:
parent
fab6ded8f2
commit
4e13a364a6
2 changed files with 20 additions and 1 deletions
|
@ -55,7 +55,14 @@ module ActiveSupport
|
|||
end
|
||||
|
||||
def read_multi_entries(keys, options)
|
||||
Hash[keys.map { |name| [name, read_entry(name, options)] }.keep_if { |_name, value| value }]
|
||||
values = {}
|
||||
|
||||
keys.each do |name|
|
||||
entry = read_entry(name, options)
|
||||
values[name] = entry.value if entry
|
||||
end
|
||||
|
||||
values
|
||||
end
|
||||
|
||||
def write_entry(key, value, options)
|
||||
|
|
|
@ -129,6 +129,18 @@ module LocalCacheBehavior
|
|||
end
|
||||
end
|
||||
|
||||
def test_local_cache_of_read_multi
|
||||
@cache.with_local_cache do
|
||||
@cache.write("foo", "foo", raw: true)
|
||||
@cache.write("bar", "bar", raw: true)
|
||||
values = @cache.read_multi("foo", "bar")
|
||||
assert_equal "foo", @cache.read("foo")
|
||||
assert_equal "bar", @cache.read("bar")
|
||||
assert_equal "foo", values["foo"]
|
||||
assert_equal "bar", values["bar"]
|
||||
end
|
||||
end
|
||||
|
||||
def test_middleware
|
||||
app = lambda { |env|
|
||||
result = @cache.write("foo", "bar")
|
||||
|
|
Loading…
Reference in a new issue