You are here

public function DrupalMemcached::getMulti in Zircon Profile 8

Same name and namespace in other branches
  1. 8.0 modules/memcache/src/DrupalMemcached.php \Drupal\memcache\DrupalMemcached::getMulti()

Retrieves multiple values from Memcache.

Parameters

array $keys: An array of keys for items to retrieve.

Return value

array An array of stored items, or FALSE otherwise.

Overrides DrupalMemcacheInterface::getMulti

File

modules/memcache/src/DrupalMemcached.php, line 66
Contains \Drupal\memcache\DrupalMemcached.

Class

DrupalMemcached
Class DrupalMemcached.

Namespace

Drupal\memcache

Code

public function getMulti(array $keys) {
  $full_keys = array();
  foreach ($keys as $cid) {
    $full_key = $this
      ->key($cid);
    $full_keys[$cid] = $full_key;
  }
  $results = $this->memcache
    ->getMulti($full_keys);

  // If $results is FALSE, convert it to an empty array.
  if (!$results) {
    $results = array();
  }

  // Convert the full keys back to the cid.
  $cid_results = array();
  $cid_lookup = array_flip($full_keys);
  foreach ($results as $key => $value) {
    $cid_results[$cid_lookup[$key]] = $value;
  }
  return $cid_results;
}