PHP Mysql - 在一段时间内收集数据并更新数据库的最有效方法?
我的设置是这样的。我有一个定时购买期,假设为 10 小时。我想在 15 分钟内收集数据并更新数据库以影响接下来 15 分钟的价格,依此类推。我需要为此使用 cron 作业吗?或者我可以走另一条路吗?谢谢。
My setup goes like this. I'm having a timed buying period let's say for 10 hours. I want to gather data in 15 minute periods and update my database to effect the price for the next 15 minutes and so on. Would I need to use cron jobs for this? Or is there another route I could take? Thanks.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您还可以自己刷新并使用浏览器中的计时器每十五分钟刷新一次文件
或者
您可以将此 cron 文件放入高流量网站,访问者将在其中触发 cron。
两者都相当容易设置。不管发生什么,Cron 都会运行,即使你的文件不存在,Cron 也会运行。但使用其他方法时,您需要该文件存在并运行 cron。一个缺点是您需要始终在浏览器中打开页面才能进行刷新。所以如果你有一个 cron 设置会更好。尽管页面刷新就像元刷新一样简单。一种方法可能是让一个 iframe 每隔几秒刷新一次该 cron。这意味着,如果您的网站上有 100 人在线,那么 cron 将会以设定的时间间隔由 100 个人不断更新,即使一个页面未正确加载,仍然有其他 99 个人在同一时间段中运行 cron。 iframe。
You can also refresh it yourself and use a timer in your browser to refresh the file every fifteen minutes
or
you may put this cron file to a high trafficked website where a visitor will trigger the cron.
both are fairly easy to setup. Cron would run irregardless of anything and even if your file isn't there the cron will run. But with the other methods you would require the file to be there and and run the cron. One disadvantage is that you would need the page to be open in a browser all the times for the refresh to take place. So it would be better if you have a cron setup. Although page refresh is as easy as doing a meta refresh. One way could be to have an iframe with that cron refreshing every few seconds. This would mean that if there are 100 people online on your website then the cron would be constantly updated by 100 people at set time intervals and even if one page is not loaded properly then there are still other 99 people who have the cron running in an iframe.