Ejemplo n.º 1
0
 public function createCounterIfNotExists($key)
 {
     try {
         $this->client->UpdateItem(['TableName' => 'tr_counters', 'Key' => ['counter_key' => ['S' => $key]], 'UpdateExpression' => 'SET v = :val', 'ExpressionAttributeValues' => [':val' => ['N' => 0]], 'ConditionExpression' => 'attribute_not_exists (v)']);
     } catch (DynamoDbException $e) {
         if ($e->getAwsErrorCode() === 'ConditionalCheckFailedException') {
         }
         // TODO
     }
 }