Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 3 additions & 6 deletions src/Illuminate/Cache/MemoizedStore.php
Original file line number Diff line number Diff line change
Expand Up @@ -68,12 +68,9 @@ public function many(array $keys)

if (count($missing) > 0) {
$retrieved = tap($this->repository->many($missing), function ($values) {
$this->cache = [
...$this->cache,
...collect($values)->mapWithKeys(fn ($value, $key) => [
$this->prefix($key) => $value,
]),
];
foreach ($values as $key => $value) {
$this->cache[$this->prefix($key)] = $value;
}
});
}

Expand Down
15 changes: 15 additions & 0 deletions tests/Integration/Cache/MemoizedStoreTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,21 @@ public function test_it_uses_correct_keys_for_getMultiple()
$this->assertSame($cacheValue, $memoValue);
}

public function test_it_uses_correct_keys_for_getMultiple_with_empty_prefix()
{
Cache::setPrefix(null);

$data = [
'1' => 'one',
0 => 'zero',
];
Cache::putMany($data);

$this->assertSame($data, Cache::memo()->many(array_keys($data)));
// ensure correct on the second memoized retrieval
$this->assertSame($data, Cache::memo()->many(array_keys($data)));
}

public function test_null_values_are_memoized_when_retrieving_multiple_values()
{
$live = Cache::getMultiple(['name.0', 'name.1']);
Expand Down
Loading