/** * {@inheritdoc} */ public function getOrFail($key) { KeyUtil::validate($key); $dbResult = $this->getDbRow($key); if (null === $dbResult) { throw NoSuchKeyException::forKey($key); } return Serializer::unserialize($dbResult['meta_value']); }
/** * {@inheritdoc} */ public function getOrFail($key) { KeyUtil::validate($key); try { $serialized = $this->clientGet($key); } catch (Exception $e) { throw ReadException::forException($e); } if ($this->clientNotFoundValue() === $serialized) { throw NoSuchKeyException::forKey($key); } return Serializer::unserialize($serialized); }
/** * {@inheritdoc} */ public function getOrFail($key) { KeyUtil::validate($key); try { $document = $this->collection->findOne(array('_id' => $key), array('typeMap' => self::$typeMap)); } catch (Exception $e) { throw ReadException::forException($e); } if (null === $document) { throw NoSuchKeyException::forKey($key); } return $this->unserialize->__invoke($document['value']); }
/** * {@inheritdoc} */ public function getOrFail($key) { KeyUtil::validate($key); if (!array_key_exists($key, $this->array)) { throw NoSuchKeyException::forKey($key); } return call_user_func($this->unserialize, $this->array[$key]); }
/** * {@inheritdoc} */ public function getOrFail($key) { throw NoSuchKeyException::forKey($key); }
/** * @expectedException \Webmozart\KeyValueStore\Api\NoSuchKeyException */ public function testGetOrFailForwardsNoSuchKeyException() { $this->cache->expects($this->once())->method('contains')->with('key')->willReturn(false); $this->innerStore->expects($this->once())->method('getOrFail')->willThrowException(NoSuchKeyException::forKey('key')); $this->cache->expects($this->never())->method('save'); $this->decorator->getOrFail('key'); }
/** * {@inheritdoc} */ public function getOrFail($key) { KeyUtil::validate($key); try { $object = $this->client->bucket($this->bucketName)->getBinary($key); $exists = $object->exists(); } catch (Exception $e) { throw ReadException::forException($e); } if (!$exists) { throw NoSuchKeyException::forKey($key); } return Serializer::unserialize($object->getData()); }
/** * {@inheritdoc} */ public function getMultipleOrFail(array $keys) { $values = array(); $data = $this->load(); foreach ($keys as $key) { KeyUtil::validate($key); if (!array_key_exists($key, $data)) { throw NoSuchKeyException::forKey($key); } $values[$key] = $this->unserializeValue($data[$key]); } return $values; }