Simplified way to fetch multiple entries when index does not matter
This commit is contained in:
parent
012f33524b
commit
dbc29d28d2
@ -100,30 +100,19 @@ class DefaultRegion implements Region
|
|||||||
*/
|
*/
|
||||||
public function getMultiple(CollectionCacheEntry $collection)
|
public function getMultiple(CollectionCacheEntry $collection)
|
||||||
{
|
{
|
||||||
$keysToRetrieve = array();
|
$result = array();
|
||||||
|
|
||||||
foreach ($collection->identifiers as $index => $key) {
|
foreach ($collection->identifiers as $key) {
|
||||||
$keysToRetrieve[$index] = $this->name . '_' . $key->hash;
|
$entry = $this->cache->fetch($this->name . '_' . $key->hash);
|
||||||
}
|
if ($entry === false) {
|
||||||
|
$result = null;
|
||||||
$items = array_filter(
|
break;
|
||||||
array_map([$this->cache, 'fetch'], $keysToRetrieve),
|
} else {
|
||||||
function ($retrieved) {
|
$result[] = $entry;
|
||||||
return false !== $retrieved;
|
|
||||||
}
|
}
|
||||||
);
|
|
||||||
|
|
||||||
if (count($items) !== count($keysToRetrieve)) {
|
|
||||||
return null;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
$returnableItems = array();
|
return $result;
|
||||||
|
|
||||||
foreach ($keysToRetrieve as $index => $key) {
|
|
||||||
$returnableItems[$index] = $items[$index];
|
|
||||||
}
|
|
||||||
|
|
||||||
return $returnableItems;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
Loading…
Reference in New Issue
Block a user