Skip to content

Instantly share code, notes, and snippets.

@mk0y
Created June 12, 2012 11:35
Show Gist options
  • Save mk0y/2917015 to your computer and use it in GitHub Desktop.
Save mk0y/2917015 to your computer and use it in GitHub Desktop.
DynamoDB example
require_once dirname(__FILE__) . '/sdk-1.5.6.2/sdk.class.php';
$dynamodb = new AmazonDynamoDB();
// set closest region
$dynamodb->set_hostname("http://dynamodb.eu-west-1.amazonaws.com");
// Name for your table
$table_name = "ObjectsTest";
// This is how they suggest to initialize the table
do {
sleep(1);
$response = $dynamodb->describe_table(array(
'TableName' => $table_name
));
}
while ((string) $response->body->Table->TableStatus !== 'ACTIVE');
// Creating the table with attributes
$response = $dynamodb->create_table(array(
'TableName' => $table_name,
'KeySchema' => array(
'HashKeyElement' => array(
'AttributeName' => 'Id',
'AttributeType' => AmazonDynamoDB::TYPE_NUMBER
)
),
'ProvisionedThroughput' => array(
'ReadCapacityUnits' => 10,
'WriteCapacityUnits' => 5
)
));
if ($response->isOK()){
ok...
} else {
not ok...
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment