/** * {@inheritdoc} */ protected function write(array $record) { $filtered = $this->filterEmptyFields($record['formatted']); if ($this->version === 3) { $formatted = $this->marshaler->marshalItem($filtered); } else { $formatted = $this->client->formatAttributes($filtered); } $this->client->putItem(['TableName' => $this->table, 'Item' => $formatted]); }
/** * @depends testIteratesOverScan */ public function testImplementsCustomExponentialBackoffStrategy() { self::log('Getting an item a bunch of times in parallel'); $batch = BatchBuilder::factory()->transferCommands(100)->build(); $s = microtime(true); $total = 300; for ($i = 0; $i < $total; $i++) { $command = $this->client->getCommand('GetItem', array('TableName' => $this->table, 'Key' => $this->client->formatAttributes(array('HashKeyElement' => 'Test', 'RangeKeyElement' => 10)))); $batch->add($command); } $retries = 0; foreach ($batch->flush() as $command) { $retries += $command->getRequest()->getParams()->get(BackoffPlugin::RETRY_PARAM); } $elapsed = microtime(true) - $s; self::log("Got the item {$total} times with {$retries} retries in {$elapsed} seconds"); }
/** * {@inheritDoc} */ public function insert($storageName, $key, array $data) { $this->createTable($storageName); $this->prepareData($key, $data); $result = $this->client->putItem(['TableName' => $storageName, 'Item' => $this->client->formatAttributes($data), 'ReturnConsumedCapacity' => 'TOTAL']); }
/** * {@inheritdoc} */ protected function write(array $record) { $filtered = $this->filterEmptyFields($record['formatted']); $formatted = $this->client->formatAttributes($filtered); $this->client->putItem(array('TableName' => $this->table, 'Item' => $formatted)); }
/** * Formats an array of values as DynamoDB attributes. * * @param array $values The values to format for DynamoDB. * @param string $format The type of format (e.g. put, update). * * @return array The formatted values */ public function formatAttributes(array $values, $format = Attribute::FORMAT_PUT) { return $this->client->formatAttributes($values, $format); }