简体   繁体   English

PHP-处理大量数据的最佳方法是什么

[英]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.

相关问题 存储大量数据php / mysql的复杂关系的最佳方法 - Best way to store complex relations of huge amount of data php/mysql 处理PHP魔术方法中“未找到”案例的最佳方法是什么? - What's the best way to deal with “not found” cases on PHP magic methods? 用PHP发送大量电子邮件的最佳方法 - Best way to send huge amount of e-mails in PHP Laravel - 从请求中更新大量数据的最佳方法? - Laravel - best way to update huge amount of data from request? 在PHP网页上加载大量数据的有效方法 - Efficient Way of Loading Huge Amount of Data on PHP Web Page PHP的自然排序内存问题涉及大量数据 - PHP's natural sort memory issue on huge amount of data 在PHP中解析一个巨大的字符串并使用RegEx来提取数据的最佳方法是什么 - What is the best way to parse a huge string in PHP and use RegEx to extract data 什么是出口巨大的Magento目录的最佳方式 - What's the best way to export huge Magento catalogs 在 foreach 中处理 codeigniter php array_merge 的最佳方法是什么? - What the best way to deal with codeigniter php array_merge, in a foreach? 处理包含无效字符(PHP)的XML的最佳方法是什么? - What is the best way to deal with XML that contains invalid characters (PHP)?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM