You are here

public function Cache::getMultiple in MongoDB 7

File

mongodb_cache/mongodb_cache_plugin.php, line 210

Class

Cache
MongoDB cache implementation.

Namespace

Drupal\mongodb_cache

Code

public function getMultiple(&$cids) {
  $cache = [];
  try {

    // Garbage collection necessary when enforcing a minimum cache lifetime.
    $this
      ->garbageCollection();
    $criteria = [
      '_id' => [
        '$in' => array_map('strval', $cids),
      ],
    ];
    $result = $this->collection
      ->find($criteria);
    foreach ($result as $item) {
      $item = $this
        ->prepareItem($item);
      if ($item) {
        $cache[$item->cid] = $item;
      }
    }
    $cids = array_diff($cids, array_keys($cache));
  } catch (\MongoConnectionException $e) {
    self::notifyException($e);
  }
  return $cache;
}