update_table ( $opt )

Updates the provisioned throughput for the given table.

Setting the throughput for a table helps you manage performance and is part of the Provisioned Throughput feature of Amazon DynamoDB.

Access

public

Parameters

Parameter

Type

Required

Description

$opt

array

Optional

An associative array of parameters that can have the following keys:

  • TableName - string - Required - The name of the table you want to update. Allowed characters are a-z, A-Z, 0-9, _ (underscore), - (hyphen) and . (period). [Constraints: The value must be between 3 and 255 characters, and must match the following regular expression pattern: [a-zA-Z0-9_.-]+]
  • ProvisionedThroughput - array - Required - Provisioned throughput reserves the required read and write resources for your table in terms of ReadCapacityUnits and WriteCapacityUnits. Values for provisioned throughput depend upon your expected read/write rates, item size, and consistency. Provide the expected number of read and write operations, assuming an item size of 1k and strictly consistent reads. For 2k item size, double the value. For 3k, triple the value, etc. Eventually-consistent reads consume half the resources of strictly consistent reads.
    • ReadCapacityUnits - long - Required - ReadCapacityUnits are in terms of strictly consistent reads, assuming items of 1k. 2k items require twice the ReadCapacityUnits. Eventually-consistent reads only require half the ReadCapacityUnits of stirctly consistent reads.
    • WriteCapacityUnits - long - Required - WriteCapacityUnits are in terms of strictly consistent reads, assuming items of 1k. 2k items require twice the WriteCapacityUnits.
  • curlopts - array - Optional - A set of values to pass directly into curl_setopt(), where the key is a pre-defined CURLOPT_* constant.
  • returnCurlHandle - boolean - Optional - A private toggle specifying that the cURL handle be returned rather than actually completing the request. This toggle is useful for manually managed batch requests.

Returns

Type

Description

CFResponse

A CFResponse object containing a parsed HTTP response.

Examples

Create a new table with a Hash Key.

// Instantiate the class
$dynamodb = new AmazonDynamoDB();

$table_name = 'my-table' . time();

####################################################################
# Create a new DynamoDB table

$response = $dynamodb->create_table(array(
	'TableName' => $table_name,
	'KeySchema' => array(
		'HashKeyElement' => array(
			'AttributeName' => 'ID',
			'AttributeType' => AmazonDynamoDB::TYPE_NUMBER
		),
		'RangeKeyElement' => array(
			'AttributeName' => 'Date',
			'AttributeType' => AmazonDynamoDB::TYPE_NUMBER
		)
	),
	'ProvisionedThroughput' => array(
		'ReadCapacityUnits' => 50,
		'WriteCapacityUnits' => 50
	)
));

// Check for success...
if ($response->isOK())
{
	echo '# Kicked off the creation of the DynamoDB table...' . PHP_EOL;
}
else
{
	print_r($response);
}

####################################################################
# Sleep and poll until the table has been created

$count = 0;
do {
	sleep(1);
	$count++;

	$response = $dynamodb->describe_table(array(
		'TableName' => $table_name
	));
}
while ((string) $response->body->Table->TableStatus !== 'ACTIVE');

echo "The table \"${table_name}\" has been created (slept ${count} seconds)." . PHP_EOL;

####################################################################
# Collect all table names in the account

echo PHP_EOL . PHP_EOL;
echo '# Collecting a complete list of tables in the account...' . PHP_EOL;

$response = $dynamodb->list_tables();
print_r($response->body->TableNames->to_array()->getArrayCopy());

####################################################################
# Describe a specific table

echo PHP_EOL . PHP_EOL;
echo "# Describing the \"${table_name}\" table..." . PHP_EOL;

$response = $dynamodb->describe_table(array(
	'TableName' => $table_name
));

print_r($response->body);

####################################################################
# Updating the table

echo PHP_EOL . PHP_EOL;
echo "# Updating the \"${table_name}\" table..." . PHP_EOL;

$dynamodb->update_table(array(
	'TableName' => $table_name,
	'ProvisionedThroughput' => array(
		'ReadCapacityUnits' => 400,
		'WriteCapacityUnits' => 400
	)
));

$table_status = $dynamodb->describe_table(array(
	'TableName' => $table_name
));

// Check for success...
if ($table_status->isOK())
{
	print_r($table_status->body->Table->ProvisionedThroughput->to_array()->getArrayCopy());
}
else
{
	print_r($table_status);
}

####################################################################
# Sleep and poll until the table has been updated.

$count = 0;
do {
	sleep(5);
	$count += 5;

	$response = $dynamodb->describe_table(array(
		'TableName' => $table_name
	));
}
while ((string) $response->body->Table->TableStatus !== 'ACTIVE');

echo "The table \"${table_name}\" has been updated (slept ${count} seconds)." . PHP_EOL;

####################################################################
# Deleting the table

echo PHP_EOL . PHP_EOL;
echo "# Deleting the \"${table_name}\" table..." . PHP_EOL;

$response = $dynamodb->delete_table(array(
	'TableName' => $table_name
));

// Check for success...
if ($response->isOK())
{
	echo 'The table is in the process of deleting...' . PHP_EOL;
}
else
{
	print_r($response);
}

####################################################################
# Sleep and poll until the table has been deleted.

$count = 0;
do {
	sleep(1);
	$count++;

	$response = $dynamodb->describe_table(array(
		'TableName' => $table_name
	));
}
while ((integer) $response->status !== 400);

echo "The table \"${table_name}\" has been deleted (slept ${count} seconds)." . PHP_EOL;

Source

Method defined in services/dynamodb.class.php | Toggle source view (6 lines) | View on GitHub

public function update_table($opt = null)
{
    if (!$opt) $opt = array();
    
    return $this->authenticate('UpdateTable', $opt);
}

Copyright © 2010–2013 Amazon Web Services, LLC


Feedback