首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >PHP Amazon大数据

PHP Amazon大数据
EN

Stack Overflow用户
提问于 2015-12-02 12:58:58
回答 1查看 180关注 0票数 1

这是我第一次使用Amazon。

我仍然有点困惑如何存储来自数据库的50000多个结果的大量数据,并将其推送到队列中。

AWS实例

代码语言:javascript
复制
require_once __DIR__.'lib/aws/aws-autoloader.php';

try {

  $aws_sqs_client = \Aws\Sqs\SqsClient::factory(array(
     'region'  => 'eu-west-1',
     'credentials' => array(
        'key'       => AWS_ACCESS,
         'secret'   => AWS_SECRET
     )
   ));

} catch ( Exception $e ) {

}

MYSQL查询

代码语言:javascript
复制
$q = 'SELECT user_id, user_email FROM user' // This has more than 50000 rows
// Is this correct way? it will create 50000 queues?
foreach ( $q as $key => $row ) {
  $result = $client->createQueue(array(
     'QueueName' => 'string',
    'Attributes' => array(
         'Queue_key_'.$key => 'string',
     ),
  ));
}

还是需要将结果拆分为较小的结果,例如,然后计算页数

代码语言:javascript
复制
$q = 'SELECT user_id, user_email FROM user LIMIT 1000, 1' // Count total number of pages

$total_page = 500 // example;

for($i=1;$i<$total_page;$i++) { // then push it to the queue
  $result = $client->createQueue(array(
     'QueueName' => 'string',
    'Attributes' => array(
         'Queue_key_'.$i => 'LIMIT 1000, ',$i, // Mysql LIMIT
     ),
  ));
}
EN

回答 1

Stack Overflow用户

发布于 2019-09-16 10:09:39

使用上述方法创建队列时,必须将数据推送到队列中以获取结果。有一个名为sendmessage的函数,它帮助您将数据推送到SQS队列。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/34043395

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档