You are here

public static function MemcacheStorageAPI::getMultiple in Memcache Storage 7

Get values from memcache storage. Provide debug logging.

See also

http://www.php.net/manual/en/memcache.get.php

3 calls to MemcacheStorageAPI::getMultiple()
MemcacheStorage::getMultiple in ./memcache_storage.inc
Implements DrupalCacheInterface::getMultiple().
MemcacheStorage::__construct in ./memcache_storage.inc
Constructs a new MemcacheStorage object.
MemcacheStorageAPI::get in ./memcache_storage.api.inc
Get single cache value from memcached pool.

File

./memcache_storage.api.inc, line 203
Provide class that processes memcached operations.

Class

MemcacheStorageAPI
Integrates with memcache API.

Code

public static function getMultiple($cache_ids, $cache_bin = '') {

  // Get memcached object.
  $memcache = self::openConnection($cache_bin);

  // No memcached connection.
  if (empty($memcache)) {
    return FALSE;
  }

  // Process cache keys.
  $cids = array();
  foreach ($cache_ids as $cache_id) {
    $safe_key = self::preprocessCacheKey($cache_id, $cache_bin);
    $cids[$safe_key] = $cache_id;
  }

  // Run initial debug actions.
  if (variable_get('memcache_storage_debug', FALSE)) {
    self::initialDebugActions();
  }

  // Fetch data from memcached pool.
  $cache = array();
  if ($memcache instanceof Memcache) {
    $cache = @$memcache
      ->get(array_keys($cids));
  }
  elseif ($memcache instanceof Memcached) {
    $cache = @$memcache
      ->getMulti(array_keys($cids));
  }

  // Return cache with correct keys.
  $output = array();
  if (!empty($cache)) {
    $cache_keys = array_keys($cache);
    foreach ($cache_keys as $cache_key) {
      $output[$cids[$cache_key]] = $cache[$cache_key];
    }
  }

  // Run final debug actions.
  if (variable_get('memcache_storage_debug', FALSE)) {
    self::finalDebugActions('get', $cache_bin, array_values($cids), $cids, $output);
  }
  return $output;
}