The BatchPutAttributes operation creates or replaces attributes within one or more items.
Attributes are uniquely identified within an item by their name/value combination. For example, a single item can
have the attributes { "first_name", "first_value" }
and {"first_name", "second_value" }
.
However, it cannot have two attribute instances where both the item attribute name and item attribute value are
the same.
Optionally, the requester can supply the Replace
parameter for each individual value. Setting this value to
true will cause the new attribute value to replace the existing attribute value(s). For example, if an item I has the
attributes { 'a', '1' }, { 'b', '2'}
and { 'b', '3' }
and the requester does a
BatchPutAttributes
of {'I', 'b', '4' }
with the Replace
parameter set to true,
the final attributes of the item will be { ‘a’, ‘1’ } and { ‘b’, ‘4’ }, replacing the previous values of the ‘b’
attribute with the new value. You cannot specify an empty string as an item or attribute name.
The BatchPutAttributes operation succeeds or fails in its entirety. There are no partial puts. You can execute multiple BatchPutAttributes operations and other operations in parallel. However, large numbers of concurrent BatchPutAttributes calls can result in Service Unavailable (503) responses. The following limitations are enforced for this operation:
- 256 attribute name-value pairs per item
- 1 MB request size
- 1 billion attributes per domain
- 10 GB of total user data storage per domain
- 25 item limit per BatchPutAttributes operation
Access
public
Parameters
Parameter |
Type |
Required |
Description |
---|---|---|---|
|
Required |
The name of the domain in which the attributes are being deleted. |
|
|
Required |
Associative array of parameters which are treated as item-key-value and item-key-multivalue pairs (i.e. a key can have one or more values; think tags). < ul> [item] - array - Set the custom item name as the key for this value.
|
|
|
Optional |
Whether to replace a key-value pair if a matching key already exists. Supports either a boolean (which affects ALL key-value pairs) or an indexed array of key names (which affects only the keys specified). Defaults to boolean |
|
|
Optional |
An associative array of parameters that can have the following keys:
|
Returns
Type |
Description |
---|---|
A |
Examples
Add a series of item-key-value pairs.
// Instantiate $sdb = new AmazonSDB(); // Test data $response = $sdb->batch_put_attributes('example-domain', array( 'item1' => array( 'key1' => 'value1', 'key2' => array( 'value1', 'value2', 'value3', ), 'key3' => array('value1'), 'key99' => 'value1', ), 'item2' => array( 'key1' => 'value1', 'key2' => array( 'value1', 'value2', 'value3', ), 'key3' => array('value1'), ), 'item3' => array( 'key1' => 'value1', 'key2' => array( 'value1', 'value2', 'value3', ), 'key3' => array('value1'), ), )); // Success? var_dump($response->isOK());Result:
bool(true)
Add a series of item-key-value pairs, replacing all duplicates.
// Instantiate $sdb = new AmazonSDB(); // Test data $response = $sdb->batch_put_attributes('example-domain', array( 'item1' => array( 'key1' => 'value1', 'key2' => array( 'value1', 'value2', 'value3', ), 'key3' => array('value1'), ), 'item2' => array( 'key1' => 'value1', 'key2' => array( 'value1', 'value2', 'value3', ), 'key3' => array('value1'), ), 'item3' => array( 'key1' => 'value1', 'key2' => array( 'value1', 'value2', 'value3', ), 'key3' => array('value1'), ), ), true); // Success? var_dump($response->isOK());Result:
bool(true)
Related Methods
Source
Method defined in services/sdb.class.php | Toggle source view (19 lines) | View on GitHub