/** * @param $identifier * @return BlogPostInterface|null */ public function getBlogPost($identifier) { $getOutput = $this->bucket->get($identifier); if ($getOutput->hasObject()) { $obj = $getOutput->getFirstObject(); $content = $obj->getContent(); if (!$obj->isDeleted() && isset($content)) { return RiakBlogPost::instanceFromJsonString($content); } } return null; }
/** * {@inheritdoc} */ protected function doContains($id) { try { // We only need the HEAD, not the entire object $input = new Input\GetInput(); $input->setReturnHead(true); $response = $this->bucket->get($id, $input); // No objects found if (!$response->hasObject()) { return false; } $object = $response->getFirstObject(); // Check for expired object if ($this->isExpired($object)) { $this->bucket->delete($object); return false; } return true; } catch (Exception\RiakException $e) { // Do nothing } return false; }
/** * {@inheritdoc} */ protected function doContains($id) { try { $input = new Input\GetInput(); $input->setReturnHead(true); $response = $this->bucket->get(urlencode($id), $input); // No objects found if (!$response->hasObject()) { return false; } $object = $response->getFirstObject(); if ($this->isExpired($object)) { return false; } return true; } catch (Exception\RiakException $e) { // Do nothing } return false; }