/** * {@inheritdoc} */ public function getMultipleOrFail(array $keys) { KeyUtil::validateMultiple($keys); // Normalize indices of the array $keys = array_values($keys); $values = array(); $notFoundKeys = array(); try { $serializedValues = $this->clientGetMultiple($keys); } catch (Exception $e) { throw ReadException::forException($e); } foreach ($serializedValues as $i => $serializedValue) { if ($this->clientNotFoundValue() === $serializedValue) { $notFoundKeys[] = $keys[$i]; } elseif (0 === count($notFoundKeys)) { $values[$keys[$i]] = Serializer::unserialize($serializedValue); } } if (0 !== count($notFoundKeys)) { throw NoSuchKeyException::forKeys($notFoundKeys); } return $values; }
/** * {@inheritdoc} */ public function getMultipleOrFail(array $keys) { KeyUtil::validateMultiple($keys); // Normalize indices of the array $keys = array_values($keys); $data = $this->doGetMultiple($keys); $results = array(); $resolved = array(); foreach ($data as $row) { $results[$row['meta_key']] = Serializer::unserialize($row['meta_value']); $resolved[] = $row['meta_key']; } $notResolvedArr = array_diff($keys, $resolved); if (!empty($notResolvedArr)) { throw NoSuchKeyException::forKeys($notResolvedArr); } return $results; }
/** * {@inheritdoc} */ public function getMultipleOrFail(array $keys) { KeyUtil::validateMultiple($keys); $values = array(); try { $cursor = $this->collection->find(array('_id' => array('$in' => array_values($keys))), array('typeMap' => self::$typeMap)); foreach ($cursor as $document) { $values[$document['_id']] = $this->unserialize->__invoke($document['value']); } } catch (UnserializationFailedException $e) { throw $e; } catch (Exception $e) { throw ReadException::forException($e); } $notFoundKeys = array_diff($keys, array_keys($values)); if (count($notFoundKeys) > 0) { throw NoSuchKeyException::forKeys($notFoundKeys); } return $values; }
/** * {@inheritdoc} */ public function getMultipleOrFail(array $keys) { KeyUtil::validateMultiple($keys); $notFoundKeys = array_diff($keys, array_keys($this->array)); if (count($notFoundKeys) > 0) { throw NoSuchKeyException::forKeys($notFoundKeys); } return $this->getMultiple($keys); }
/** * {@inheritdoc} */ public function getMultipleOrFail(array $keys) { throw NoSuchKeyException::forKeys($keys); }
/** * {@inheritdoc} */ public function getMultipleOrFail(array $keys) { KeyUtil::validateMultiple($keys); $values = array(); $notFoundKeys = array(); try { $bucket = $this->client->bucket($this->bucketName); foreach ($keys as $key) { $values[$key] = $bucket->getBinary($key); if (!$values[$key]->exists()) { $notFoundKeys[] = $key; } } } catch (Exception $e) { throw ReadException::forException($e); } if (0 !== count($notFoundKeys)) { throw NoSuchKeyException::forKeys($notFoundKeys); } foreach ($values as $key => $object) { $values[$key] = Serializer::unserialize($object->getData()); } return $values; }