function ApcuBackend::getMultiple

Same name and namespace in other branches
  1. 11.x 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;
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.