[英]PHP - What's the best way to deal with huge amount of data
感谢您的阅读,我正在magento网站上工作。 就我而言,我想使用cron将所有产品数据存储在.json文件中。 有14家商店,每个商店都有2000多种产品,并且商店和产品数量都在增长。 总体算法如下:
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
]
问题是所需的内存很大,我正在考虑将每200个产品的数据保存在temp json中,最后加载所有temp json文件并将它们合并到一个大json中。
最好的解决方法是什么? 我的解决方案好吗? 提前致谢
使用magento core / resource_iterator模型。 可以在以下网址找到一个很好的解释: http : //www.atwix.com/magento/working-with-large-collections/
编辑:使用此配方,您可以获得一个不错的关联数组,可以序列化或jsonify。 我想序列化会更快。
我倾向于不问为什么有人要这样做! 我不知道您想用任何非sql格式的产品数据实现什么。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.