php - 在本地数据库中存储Amazon API数据

原文 标签 php mysql api amazon-web-services walmart-api

Storing Amazon API data in Local Database

I'm working on a site that pulls product price data from and Walmart. I'm guessing that in the future, it will also pull data from other places.

My first idea was to pull the data directly from Amazon (using their product advertising API) and then display the data on the site for every single visitor who landed on the page. That's not a bad idea if there aren't many product prices I'll be retrieving (or if the number of site visitors is low). I think that I will run into problems once the site gets busy and if i increase the number of product whose price i want to pull.

Using the Amazon and Walmart API, i was able to make successful REST api calls and parse the XML returned to obtain the information that i needed.

Does it make sense to store that information in a local database, update it say, every 1-5 minutes, and then get the site visitors to pull the pricing information from my local database instead of making an API call to Amazon and Walmart?

If I do go this route and create a function that uses the Amazon and Walmart API to pull price data, how do I then automatically run this function every 1 to 5 minutes in the background, 24/7/365?


Does it make sense to store that information in a local database

Yes. Actually this sounds exactly like a typical caching setup. I would recommend looking into Redis instead of using a relational database for this.

how do I then automatically run this function every 1 to 5 minutes in the background

Probably a Cron job. You would have to provide more information like where your application is running (AWS EC2 or somewhere else?) and if it is running on Linux or Windows, before I could give a more detailed recommendation.




使用Amazon和Walmart API,我能够成功进行REST api调用,并解析返回的XML以获取所需的信息。


如果我按此路线创建了一个使用Amazon和Walmart API提取价格数据的函数,那么我如何在后台24/7/365每1至5分钟自动运行一次此函数?



可能是Cron工作。您必须提供更多信息,例如您的应用程序在何处运行(AWS EC2或其他地方?),以及它是否在Linux或Windows上运行,然后才能给出更详细的建议。

php - PHP表格检查数组mysql中的复选框值时查询?

php - 无法从数组获取正确的值

php - cakePHP在模型中使用请求/身份验证数据的3个最佳实践(基于帐户的云服务)

php - 什么数据类型可用于在mysql中放置标志(布尔值)?

javascript - 尝试将数据从.php文件传递到.js文件

php - 更改子菜单时如何更改网页背景?

php - Symfony2:如何避免数据库中已经存在重复的实体?

php - Eclipse中的PHP 7调试器设置

javascript - 访问URL参数-PHP和Angular.js

php - 使用更新的MySQL库修复PHP数据库连接失败