[英]PHP - What's the best way to deal with huge amount of data
Thanks for reading, I'm working on magento website. 感谢您的阅读,我正在magento网站上工作。 in my case I want to store all products data in .json files using cron.
就我而言,我想使用cron将所有产品数据存储在.json文件中。 There are 14 stores and each has more than 2000 products and it's growing in both store and product number.
有14家商店,每个商店都有2000多种产品,并且商店和产品数量都在增长。 the over all algorithm as the following:
总体算法如下:
foreach available store
[
define globalArray = array()
get store products collection
foreach product
[
add product data to globalArray
add product filterable attributes to globalArray
...
]
save globalArray in json file
]
The problem is the required memory is very big, I'm thinking about saving the data for each 200 product in temp json and at the end load all temp json file and merge them in one big json . 问题是所需的内存很大,我正在考虑将每200个产品的数据保存在temp json中,最后加载所有temp json文件并将它们合并到一个大json中。
What could be the best way to deal with that? 最好的解决方法是什么? and is my solution good?
我的解决方案好吗? thanks in advance
提前致谢
Use the magento core/resource_iterator model. 使用magento core / resource_iterator模型。 A nice explanation can be found at: http://www.atwix.com/magento/working-with-large-collections/
可以在以下网址找到一个很好的解释: http : //www.atwix.com/magento/working-with-large-collections/
EDIT: With this recipe you get a nice associative array which you can serialize or jsonify. 编辑:使用此配方,您可以获得一个不错的关联数组,可以序列化或jsonify。 I guess serializing is quicker.
我想序列化会更快。
I tend to not ask why someone wants to do this! 我倾向于不问为什么有人要这样做! I have no clue what you want to achieve with the product data in any non sql format.
我不知道您想用任何非sql格式的产品数据实现什么。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.