You are here

function DrupalAPCCache::getMultiple in APC - Alternative PHP Cache 7

Returns data from the persistent cache when given an array of cache IDs.

Parameters

$cids: An array of cache IDs for the data to retrieve. This is passed by reference, and will have the IDs successfully returned from cache removed.

Return value

An array of the items successfully returned from cache indexed by cid.

Overrides DrupalCacheInterface::getMultiple

File

./drupal_apc_cache.inc, line 176
This integrates the drupal APC cache backend.

Class

DrupalAPCCache
APC cache implementation.

Code

function getMultiple(&$cids) {
  if (!$cids) {
    return array();
  }

  // We need to search the cache with the proper keys and
  // be able to get the original $cid back.
  foreach ($cids as $cid) {
    $keys[$this
      ->key($cid)] = $cid;
  }
  $fetch = apc_fetch(array_keys($keys));
  $cache = array();
  if (!empty($fetch)) {
    foreach ($fetch as $key => $data) {
      $cache[$keys[$key]] = $this
        ->prepareItem($fetch[$key]);
    }
  }
  unset($fetch);

  // Add a get to our statistics.
  $GLOBALS['apc_statistics'][] = array(
    'get',
    $this->bin,
    $cids,
  );
  $cids = array_diff($cids, array_keys($cache));
  return $cache;
}