You are here

public function ApcuBackend::getMultiple in Drupal 10

Same name and namespace in other branches
  1. 8 core/lib/Drupal/Core/Cache/ApcuBackend.php \Drupal\Core\Cache\ApcuBackend::getMultiple()
  2. 9 core/lib/Drupal/Core/Cache/ApcuBackend.php \Drupal\Core\Cache\ApcuBackend::getMultiple()

File

core/lib/Drupal/Core/Cache/ApcuBackend.php, line 83

Class

ApcuBackend
Stores cache items in the Alternative PHP Cache User Cache (APCu).

Namespace

Drupal\Core\Cache

Code

public function getMultiple(&$cids, $allow_invalid = FALSE) {

  // Translate the requested cache item IDs to APCu keys.
  $map = [];
  foreach ($cids as $cid) {
    $map[$this
      ->getApcuKey($cid)] = $cid;
  }
  $result = apcu_fetch(array_keys($map));
  $cache = [];
  if ($result) {
    foreach ($result as $key => $item) {
      $item = $this
        ->prepareItem($item, $allow_invalid);
      if ($item) {
        $cache[$map[$key]] = $item;
      }
    }
  }
  unset($result);
  $cids = array_diff($cids, array_keys($cache));
  return $cache;
}