本文整理汇总了PHP中Aws\DynamoDb\DynamoDbClient类的典型用法代码示例。如果您正苦于以下问题:PHP DynamoDbClient类的具体用法?PHP DynamoDbClient怎么用?PHP DynamoDbClient使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了DynamoDbClient类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。
示例1: init
/**
* Initialize the dynamodb client.
*/
public function init()
{
parent::init();
//For v2 compatibility.
//TODO: remove deprecated.
$this->_client = DynamoDbClient::factory($this->config);
}
开发者ID:rifki192,项目名称:yii2-dynamodb,代码行数:10,代码来源:Connection.php
示例2: init
/**
* Initialize the client.
*/
public function init()
{
$this->_client = DynamoDbClient::factory($this->config);
if ($this->keyPrefix === null) {
$this->keyPrefix = substr(md5(Yii::$app->id), 0, 5);
}
parent::init();
}
开发者ID:urbanindo,项目名称:yii2-dynamodb-session,代码行数:11,代码来源:Session.php
示例3: __construct
public function __construct($region = false)
{
if (!$region && !($region = getenv("AWS_DEFAULT_REGION"))) {
throw new \Exception("Set 'AWS_DEFAULT_REGION' environment variable!");
}
$this->region = $region;
$this->sns = SnsClient::factory(['region' => $region]);
$this->ddb = DynamoDbClient::factory(['region' => $region]);
}
开发者ID:sportarchive,项目名称:aws-sns-php-handler,代码行数:9,代码来源:SnsHandler.php
示例4: testRemoveAKey
public function testRemoveAKey()
{
// Arrange.
$key = 'bar';
$this->mockDynamoDbClient->expects($this->once())->method('deleteItem')->with(['TableName' => $this->storeKeyTableName, 'Key' => [$this->storeKeyAttribute => ['S' => $key]]]);
// Act.
$this->storeKeyClient->delete($key);
// Assert in arrange.
}
开发者ID:wadify,项目名称:store-key-client-php,代码行数:9,代码来源:ClientTest.php
示例5: factory
/**
* Factory method to create a new Amazon DynamoDB Streams client using an array of configuration options.
*
* See http://docs.aws.amazon.com/aws-sdk-php/v2/guide/configuration.html#client-configuration-options
*
* @param array|Collection $config Client configuration data
*
* @return self
* @link http://docs.aws.amazon.com/aws-sdk-php/v2/guide/configuration.html#client-configuration-options
*/
public static function factory($config = array())
{
// Configure the custom exponential backoff plugin for DynamoDB throttling
$exceptionParser = new JsonQueryExceptionParser();
if (!isset($config[Options::BACKOFF])) {
$config[Options::BACKOFF] = new BackoffPlugin(DynamoDbClient::createDynamoDbBackoffStrategy($exceptionParser));
}
return ClientBuilder::factory(__NAMESPACE__)->setConfig($config)->setConfigDefaults(array(Options::VERSION => self::LATEST_API_VERSION, Options::SERVICE_DESCRIPTION => __DIR__ . '/Resources/dynamodbstreams-%s.php'))->setExceptionParser($exceptionParser)->build();
}
开发者ID:willyvidable,项目名称:Wordpress_4_4,代码行数:19,代码来源:DynamoDbStreamsClient.php
示例6: __construct
public function __construct()
{
$bucket = Config::get('storage.bucket', 'default');
$key = Config::get('storage.key');
$secret = Config::get('storage.secret');
$client = DynamoDbClient::factory(array('key' => $key, 'secret' => $secret, 'region' => '<region name>'));
$config = new SessionHandlerConfig(array('table_name' => 'sessions'));
// Make sure locking strategy has been provided or provide a default
$factory = new LockingStrategyFactory();
$strategy = $factory->factory($strategy, $config);
// Return an instance of the session handler
parent::__construct($client, $strategy, $config);
}
开发者ID:CFLOVEYR,项目名称:hook,代码行数:13,代码来源:AmazonAWS.php
示例7: __construct
public function __construct($connection, $config = array())
{
if (!$connection instanceof DynamoDbClient) {
if (!is_array($connection)) {
throw new \InvalidArgumentException('First argument to OAuth2\\Storage\\Dynamodb must be an instance a configuration array containt key, secret, region');
}
if (!array_key_exists("key", $connection) || !array_key_exists("secret", $connection) || !array_key_exists("region", $connection)) {
throw new \InvalidArgumentException('First argument to OAuth2\\Storage\\Dynamodb must be an instance a configuration array containt key, secret, region');
}
$this->client = DynamoDbClient::factory(array('key' => $connection["key"], 'secret' => $connection["secret"], 'region' => $connection["region"]));
} else {
$this->client = $connection;
}
$this->config = array_merge(array('client_table' => 'oauth_clients', 'access_token_table' => 'oauth_access_tokens', 'refresh_token_table' => 'oauth_refresh_tokens', 'code_table' => 'oauth_authorization_codes', 'user_table' => 'oauth_users', 'jwt_table' => 'oauth_jwt', 'scope_table' => 'oauth_scopes', 'public_key_table' => 'oauth_public_keys'), $config);
}
开发者ID:uedcw,项目名称:webstory,代码行数:15,代码来源:DynamoDB.php
示例8: get
public static function get()
{
if (LocalDBClientBuilder::$client == null) {
LocalDBClientBuilder::$client = DynamoDbClient::factory(array('region' => 'us-west-2', 'version' => 'latest', 'endpoint' => 'http://localhost:8000', 'key' => 'myKey', 'secret' => 'mySecret'));
// AMO: TODO remove debug plugin
//LocalDBClientBuilder::$client->addSubscriber(LogPlugin::getDebugPlugin());
}
return LocalDBClientBuilder::$client;
/* $sdk = new Aws\Sdk([
'region' => 'us-west-2',
'version' => 'latest',
'endpoint' => 'http://localhost:8080'
]);
$dynamodb = $sdk->createDynamoDb();*/
}
开发者ID:Cherry-project,项目名称:website,代码行数:16,代码来源:LocalDBClientBuilder.php
示例9: testClientsUseInstanceProfileCredentials
/**
* @depends testUsesInstanceProfileCredentialsByDefault
*/
public function testClientsUseInstanceProfileCredentials(array $creds)
{
$this->skipIfNotEc2();
list($credentials, $client) = $creds;
$dynamo = DynamoDbClient::factory(array('credentials' => $credentials));
// Ensure that the correct credentials object and client are being used
$this->assertSame($credentials, $dynamo->getCredentials());
if ($this->useMocks()) {
$this->setMockResponse($client, array('metadata/iam_security_credentials', 'metadata/iam_security_credentials_webapp'));
$this->setMockResponse($dynamo, 'dynamodb/list_tables_final');
}
// Expire the credentials
$credentials->setExpiration(0);
// List a table, causing a credential refresh and list table request
$this->assertInternalType('array', $dynamo->listTables());
}
开发者ID:njbhatt18,项目名称:Amazon_API,代码行数:19,代码来源:RefreshableInstanceProfileCredentialsIntegrationTest.php
示例10: __construct
public function __construct($options, $table)
{
// refer to the Session class to find the session timeout value (if it exists)
// in terms of DynamoDB, session_lifetime is the time to mark the inactive
// session to be garbage collected
// if {@link GarbageCollectSessionCronTask} is running periodically on your
// server (via the silverstripe-crontask module), then the inactive session
// will get removed from the DynamoDB session table.
if (!isset($options['session_lifetime'])) {
$timeout = Config::inst()->get('Session', 'timeout');
if ($timeout != null) {
$options['session_lifetime'] = $timeout;
}
}
$this->client = DynamoDbClient::factory($options);
$this->table = $table;
$this->handler = SessionHandler::factory(array('dynamodb_client' => $this->client, 'table_name' => $this->table));
}
开发者ID:helpfulrobot,项目名称:silverstripe-dynamodb,代码行数:18,代码来源:DynamoDbSession.php
示例11: processMessage
/**
* Processes message from SQS Queue
* @param QueueMessage $message
*/
private function processMessage(QueueMessage $message)
{
$body = \Keboola\Utils\objectToArray($message->getBody());
if (isset($body['container_id'], $body['container_name'], $body['container_stats'])) {
$containerName = $body['container_name'];
$jobIdAndRunId = $this->getJobIdAndRunIdFromContainerName($containerName);
if (!empty($jobIdAndRunId)) {
$containerStats = $body['container_stats'];
$networkRxBytes = strval(isset($containerStats['network']['rx_bytes']) ? $containerStats['network']['rx_bytes'] : 0);
$networkTxBytes = strval(isset($containerStats['network']['tx_bytes']) ? $containerStats['network']['tx_bytes'] : 0);
$updateExpression = 'SET dockerNetwork = :dockerNetwork';
$expressionAttributeValues = [':dockerNetwork' => ['M' => ['rxBytes' => ['N' => $networkRxBytes], 'txBytes' => ['N' => $networkTxBytes]]], ':newRxBytes' => ['N' => $networkRxBytes], ':newTxBytes' => ['N' => $networkTxBytes]];
$updateExpression .= ', syrupJobId = if_not_exists(syrupJobId, :syrupJobId)';
$expressionAttributeValues[':syrupJobId'] = ['S' => $jobIdAndRunId['jobId']];
$params = ['TableName' => $this->tableName, 'Key' => ['runId' => ['S' => $jobIdAndRunId['runId']]], 'UpdateExpression' => $updateExpression, 'ConditionExpression' => <<<EXPR
attribute_not_exists(dockerNetwork)
or (dockerNetwork.rxBytes < :newRxBytes or dockerNetwork.txBytes < :newTxBytes)
EXPR
, 'ExpressionAttributeValues' => $expressionAttributeValues, 'ReturnValues' => 'UPDATED_NEW'];
try {
$this->dynamoDbClient->updateItem($params);
} catch (DynamoDbException $e) {
if (strpos($e->getMessage(), 'ConditionalCheckFailedException') === false) {
throw $e;
}
}
}
}
}
开发者ID:keboola,项目名称:syrup-queue,代码行数:33,代码来源:MetricsProcessContainerStatsCommand.php
示例12: execute
protected function execute(InputInterface $input, OutputInterface $output)
{
$this->dynamoDbClient = $this->getContainer()->get('queue.dynamodb_client');
$this->tableName = $this->getContainer()->getParameter('container_stats_dynamodb.table_name');
$tableName = $this->tableName;
$updateTableJson = <<<JSON
{
"TableName": "{$tableName}",
"GlobalSecondaryIndexUpdates": [
{
"Create": {
"IndexName": "sapiProjectId-sapiCreatedTime-index",
"KeySchema": [
{
"AttributeName": "sapiProjectId",
"KeyType": "HASH"
},
{
"AttributeName": "sapiCreatedTime",
"KeyType": "RANGE"
}
],
"Projection": {
"ProjectionType": "ALL"
},
"ProvisionedThroughput": {
"ReadCapacityUnits": 3,
"WriteCapacityUnits": 7
}
}
}
],
"AttributeDefinitions": [
{
"AttributeName": "sapiCreatedTime",
"AttributeType": "S"
},
{
"AttributeName": "sapiProjectId",
"AttributeType": "S"
}
]
}
JSON;
$updateTableArgs = \json_decode($updateTableJson, true);
try {
$this->dynamoDbClient->updateTable($updateTableArgs);
echo 'Index has been created' . "\n";
} catch (DynamoDbException $e) {
if (strpos($e->getMessage(), 'Attempting to create an index which already exists') !== false) {
echo 'Index already exists' . "\n";
} else {
throw $e;
}
}
}
开发者ID:keboola,项目名称:syrup-queue,代码行数:57,代码来源:MetricsAddProjectAndDateIndexCommand.php
示例13: saveData
/**
* Save marshaled data
*
* @param $id
* @param $data
* @return bool|\Guzzle\Service\Resource\Model
*/
public function saveData($id, $data)
{
if (empty($this->table)) {
return false;
}
$client_data = ['TableName' => $this->table, 'Item' => ['id' => ['S' => $id], 'item_status' => ['S' => 'entered'], 'payload' => ['M' => $this->marshallData($data)], 'date' => ['S' => utf8_encode((string) date('Y-m-d H:i:s'))]]];
$result = $this->client->putItem($client_data);
return $result;
}
开发者ID:kameshwariv,项目名称:testexample,代码行数:16,代码来源:Ddb.php
示例14: saved
public function saved($model)
{
$attrs = $model->attributesToArray();
// $this->attributeFilter->filter($attrs);
try {
$this->dynamoDbClient->putItem(['TableName' => $model->getDynamoDbTableName(), 'Item' => $this->marshaler->marshalItem($attrs)]);
} catch (Exception $e) {
Log::info($e);
}
}
开发者ID:warrick-loyaltycorp,项目名称:laravel-dynamodb,代码行数:10,代码来源:ModelObserver.php
示例15: storeReferralCode
public function storeReferralCode($code, $user_id, $timestamp)
{
$data = ['code' => $code, 'user_id' => $user_id, 'timestamp' => $timestamp];
// TODO error handling
$response = $this->client->GetItem(['TableName' => 'tr_referralcodes', 'Key' => ['code' => ['S' => $code]]]);
if (!empty($response['Item'])) {
throw new \Exception('Code already exists');
}
$this->client->PutItem(['TableName' => 'tr_referralcodes', 'Item' => $this->marshaler->marshalItem($data)]);
}
开发者ID:jacksteadman,项目名称:tracer2,代码行数:10,代码来源:DynamoDb.php
示例16: write
/**
* {@inheritdoc}
*/
protected function write(array $record)
{
$filtered = $this->filterEmptyFields($record['formatted']);
if ($this->version === 3) {
$formatted = $this->marshaler->marshalItem($filtered);
} else {
$formatted = $this->client->formatAttributes($filtered);
}
$this->client->putItem(['TableName' => $this->table, 'Item' => $formatted]);
}
开发者ID:earncef,项目名称:monolog,代码行数:13,代码来源:DynamoDbHandler.php
示例17: seed
protected function seed($attributes = [])
{
$item = ['id' => ['S' => str_random(36)], 'name' => ['S' => str_random(36)], 'description' => ['S' => str_random(256)], 'count' => ['N' => rand()]];
$item = array_merge($item, $attributes);
$this->dynamoDbClient->putItem(['TableName' => $this->testModel->getTable(), 'Item' => $item]);
return $item;
}
开发者ID:warrick-loyaltycorp,项目名称:laravel-dynamodb,代码行数:7,代码来源:DynamoDbModelTest.php
示例18: getJobsToFetchStatsFor
/**
* Scans table for specific items we want to update
* @return array
*/
private function getJobsToFetchStatsFor()
{
$params = ['TableName' => $this->tableName, 'FilterExpression' => <<<EXPR
attribute_exists(sapiProjectId)
and attribute_not_exists(componentName)
and not begins_with(runId, :notBeginsWith)
and (
attribute_not_exists(syrupJobId)
or
(attribute_exists(syrupJobId) and syrupJobId <> :syrupJobIdSyncAction)
)
and attribute_not_exists(hasSyrupJob)
EXPR
, 'Limit' => self::MAX_DOCUMENTS_TO_PROCESS, 'ExpressionAttributeValues' => [':notBeginsWith' => ['S' => 'p'], ':syrupJobIdSyncAction' => ['S' => '0']]];
$ids = [];
$marshaler = new Marshaler();
do {
if (isset($response) && isset($response['LastEvaluatedKey'])) {
$params['ExclusiveStartKey'] = $response['LastEvaluatedKey'];
}
$response = $this->dynamoDbClient->scan($params);
foreach ($response['Items'] as $item) {
$ids[] = $marshaler->unmarshalValue($item['runId']);
}
} while (isset($response['LastEvaluatedKey']) && count($ids) <= 5000);
return $ids;
}
开发者ID:keboola,项目名称:syrup-queue,代码行数:31,代码来源:MetricsProcessElasticStatsCommand.php
示例19: getAll
protected function getAll($columns = [], $limit = -1)
{
$query = ['TableName' => $this->getTable()];
$op = 'Scan';
if ($limit > -1) {
$query['limit'] = $limit;
}
if (!empty($columns)) {
$query['AttributesToGet'] = $columns;
}
// If the $where is not empty, we run getIterator.
if (!empty($this->where)) {
// Primary key or index key condition exists, then use Query instead of Scan.
// However, Query only supports a few conditions.
if ($key = $this->conditionsContainIndexKey()) {
$condition = array_get($this->where, "{$key}.ComparisonOperator");
if (ComparisonOperator::isValidQueryDynamoDbOperator($condition)) {
$op = 'Query';
$query['IndexName'] = $this->dynamoDbIndexKeys[$key];
$query['KeyConditions'] = $this->where;
}
}
$query['ScanFilter'] = $this->where;
}
$iterator = $this->client->getIterator($op, $query);
$results = [];
foreach ($iterator as $item) {
$item = $this->unmarshalItem($item);
$model = new static($item, $this->dynamoDb);
$model->setUnfillableAttributes($item);
$results[] = $model;
}
return new Collection($results);
}
开发者ID:warrick-loyaltycorp,项目名称:laravel-dynamodb,代码行数:34,代码来源:DynamoDbModel.php
示例20: listTables
/**
* List tables via the list_tables call
* @param integer $limit
* @param string $exclusiveStartTableName
* @return Table\TableCollection
*/
public function listTables($limit = null, $exclusiveStartTableName = null)
{
if (null !== $this->logger) {
$this->log('List tables');
}
$parameters = array();
if (null !== $limit) {
$parameters['Limit'] = $limit;
}
if (null !== $exclusiveStartTableName) {
$parameters['ExclusiveStartTableName'] = $exclusiveStartTableName;
}
if (null !== $this->logger) {
$this->log('ListTable request paramaters : ' . print_r($parameters, true), Logger::DEBUG);
}
$response = $this->connector->listTables($parameters);
if (null !== $this->logger) {
$this->log('ListTable request response : ' . print_r($response, true), Logger::DEBUG);
}
$tables = new Table\TableCollection(isset($response['LastEvaluatedTableName']) ? $response['LastEvaluatedTableName'] : null);
if (!empty($response['TableNames'])) {
foreach ($response['TableNames'] as $table) {
$tables->add($table);
}
}
return $tables;
}
开发者ID:16hands,项目名称:riverline-dynamodb,代码行数:33,代码来源:Connection.php
注:本文中的Aws\DynamoDb\DynamoDbClient类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论