当前位置: 首页>>代码示例>>PHP>>正文


PHP DynamoDbClient::batchWriteItem方法代码示例

本文整理汇总了PHP中Aws\DynamoDb\DynamoDbClient::batchWriteItem方法的典型用法代码示例。如果您正苦于以下问题:PHP DynamoDbClient::batchWriteItem方法的具体用法?PHP DynamoDbClient::batchWriteItem怎么用?PHP DynamoDbClient::batchWriteItem使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Aws\DynamoDb\DynamoDbClient的用法示例。


在下文中一共展示了DynamoDbClient::batchWriteItem方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: batchWrite

 /**
  * Put Items and delete Keys by batch
  * @param Context\BatchWrite $context
  * @return null|Context\BatchWrite Return a new BatchWrite context if some request were not processed
  * @throws Exception\AttributesException
  */
 public function batchWrite(Context\BatchWrite $context)
 {
     if (null !== $this->logger) {
         $this->log('BatchWrite');
     }
     if (0 === count($context)) {
         $message = "BatchWrite context doesn't contain anything to write";
         if (null !== $this->logger) {
             $this->log($message, Logger::ERROR);
         }
         throw new Exception\AttributesException($message);
     }
     $parameters = $context->getForDynamoDB();
     if (null !== $this->logger) {
         $this->log('BatchWrite request paramaters : ' . print_r($parameters, true), Logger::DEBUG);
     }
     $response = $this->connector->batchWriteItem($parameters);
     if (null !== $this->logger) {
         $this->log('BatchWrite request response : ' . print_r($response, true), Logger::DEBUG);
     }
     // UnprocessedKeys
     if (count((array) $response['UnprocessedItems'])) {
         $newContext = new Context\BatchWrite();
         foreach ($response['UnprocessedItems'] as $table => $tableParameters) {
             foreach ($tableParameters as $request) {
                 if (isset($request['DeleteRequest'])) {
                     $keys = $request['DeleteRequest']['Key'];
                     $newContext->addKeyToDelete($table, current($keys['HashKeyElement']), isset($keys['RangeKeyElement']) ? current($keys['RangeKeyElement']) : null);
                 } elseif (isset($request['PutRequest'])) {
                     $item = new Item($table);
                     $item->populateFromDynamoDB($request['PutRequest']['Item']);
                     $newContext->addItemToPut($item);
                 }
             }
         }
         if (null !== $this->logger) {
             $this->log('More unprocessed Items');
         }
     } else {
         $newContext = null;
     }
     // Write Unit
     foreach ($response['Responses'] as $table => $responseItems) {
         $this->addConsumedWriteUnits($table, floatval($responseItems['ConsumedCapacityUnits']));
     }
     return $newContext;
 }
开发者ID:16hands,项目名称:riverline-dynamodb,代码行数:53,代码来源:Connection.php

示例2: batchWriteItem

 /**
  * Executes the BatchWriteItem operation.
  *
  * @param array  $requestItems                Associative array of <TableName> keys mapping to (array<associative-array>) values.
  * @param string $returnConsumedCapacity      Sets consumed capacity return mode.
  * @param string $returnItemCollectionMetrics If set to SIZE, statistics about item collections, if any, that were modified during the operation are returned in the response.
  *
  * @return Guzzle\Service\Resource\Model
  *
  * @see http://docs.aws.amazon.com/aws-sdk-php/latest/class-Aws.DynamoDb.DynamoDbClient.html#_batchWriteItem
  */
 public function batchWriteItem(array $requestItems, $returnConsumedCapacity = self::CAPACITY_NONE, $returnItemCollectionMetrics = self::METRICS_NONE)
 {
     return $this->client->batchWriteItem(['RequestItems' => $requestItems, 'ReturnConsumedCapacity' => $returnConsumedCapacity, 'ReturnItemCollectionMetrics' => $returnItemCollectionMetrics]);
 }
开发者ID:m6web,项目名称:aws-bundle,代码行数:15,代码来源:Client.php


注:本文中的Aws\DynamoDb\DynamoDbClient::batchWriteItem方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。