Thursday, October 4, 2012

AWS Dynamo Batch Get Item


Rather than use Scan (which gives you paginated results, forcing you to essentially check every page), another option is to queue individual get_items as a batch operation and then send it:

    $dynamodb = new AmazonDynamoDB();
    $queue = new CFBatchRequest();
    foreach ($aws_ids as $aws_id)
    {
        self::$dynamodb->batch($queue)->query(array(
            'TableName' => "tablename",
            'HashKeyValue' => array( AmazonDynamoDB::TYPE_STRING => $aws_id ),
            //'AttributesToGet' => array('field1','fiedl2')
            //'Limit' => 1
        ));
    }
    $responses = $dynamodb->batch($queue)->send();

The response will be an array of what appears to be the same response type you would get from an individual request.

No comments:

Post a Comment