| @@ 76-92 (lines=17) @@ | ||
| 73 | /** |
|
| 74 | * {@inheritdoc} |
|
| 75 | */ |
|
| 76 | public function get($key, $default = null) |
|
| 77 | { |
|
| 78 | KeyUtil::validate($key); |
|
| 79 | ||
| 80 | try { |
|
| 81 | $object = $this->client->bucket($this->bucketName)->getBinary($key); |
|
| 82 | $exists = $object->exists(); |
|
| 83 | } catch (Exception $e) { |
|
| 84 | throw ReadException::forException($e); |
|
| 85 | } |
|
| 86 | ||
| 87 | if (!$exists) { |
|
| 88 | return $default; |
|
| 89 | } |
|
| 90 | ||
| 91 | return Serializer::unserialize($object->getData()); |
|
| 92 | } |
|
| 93 | ||
| 94 | /** |
|
| 95 | * {@inheritdoc} |
|
| @@ 97-113 (lines=17) @@ | ||
| 94 | /** |
|
| 95 | * {@inheritdoc} |
|
| 96 | */ |
|
| 97 | public function getOrFail($key) |
|
| 98 | { |
|
| 99 | KeyUtil::validate($key); |
|
| 100 | ||
| 101 | try { |
|
| 102 | $object = $this->client->bucket($this->bucketName)->getBinary($key); |
|
| 103 | $exists = $object->exists(); |
|
| 104 | } catch (Exception $e) { |
|
| 105 | throw ReadException::forException($e); |
|
| 106 | } |
|
| 107 | ||
| 108 | if (!$exists) { |
|
| 109 | throw NoSuchKeyException::forKey($key); |
|
| 110 | } |
|
| 111 | ||
| 112 | return Serializer::unserialize($object->getData()); |
|
| 113 | } |
|
| 114 | ||
| 115 | /** |
|
| 116 | * {@inheritdoc} |
|