Exemple #1
0
 /**
  * Return a new Database instance.
  *
  * If a logger callable was defined, a LoggableDatabase will be returned.
  *
  * @see Connection::selectDatabase()
  * @param string $name
  * @return Database
  */
 protected function doSelectDatabase($name)
 {
     $riak = $this->riakClient->selectDB($name);
     $numRetries = $this->config->getRetryQuery();
     $loggerCallable = $this->config->getLoggerCallable();
     return $loggerCallable !== null ? new LoggableDatabase($this, $riak, $this->eventManager, $numRetries, $loggerCallable) : new Database($this, $riak, $this->eventManager, $numRetries);
 }
 /**
  * {@inheritDoc}
  */
 public function find($storageName, $key)
 {
     $bucket = $this->client->bucket($storageName);
     /** @var $object \Riak\Object */
     $object = $bucket->get($key);
     if (!$object->exists()) {
         throw new NotFoundException();
     }
     return $object->getData();
 }
Exemple #3
0
 public function testMetaData()
 {
     $client = new Client($GLOBALS['RIAK_HOST'], $GLOBALS['RIAK_PORT']);
     $bucket = $client->bucket("metatest");
     # Set some meta
     $bucket->newObject("metatest", array("foo" => 'bar'))->setMeta("foo", "bar")->store();
     # Test that we load the meta back
     $object = $bucket->get("metatest");
     $this->assertEquals("bar", $object->getMeta("foo"));
     # Test that the meta is preserved when we rewrite the object
     $bucket->get("metatest")->store();
     $object = $bucket->get("metatest");
     $this->assertEquals("bar", $object->getMeta("foo"));
     # Test that we remove meta
     $object->removeMeta("foo")->store();
     $anotherObject = $bucket->get("metatest");
     $this->assertNull($anotherObject->getMeta("foo"));
 }