posts - 28,  comments - 15,  trackbacks - 0

          對于MongoDB collection下的文檔而言,在文件大于16MB時,我們應該使用GridFS。

          在一些解決方案中,使用MongoDB的GridFS存儲大文件,比使用系統級別的文件系統更便利。
          .當文件系統的目錄對文件數量有限制時,你應該使用GridFS來存儲需要的盡可能多的文件;
          .當你想讓你的文件和元數據在多個系統和設施之間自動同步和部署時。使用地理上分布的副本集(geographically distributed replica sets),MongoDB可以自動地分發文件和元數據到多個mongo實例和設施上。
          .當你想訪問大文件的部分信息,而又不想把整個文件加載到內存時,你可以使用GridFS調回部分文件,而不用把整個文件讀入到內存。

          如果你需要自動的更新文件的整個內容,不要使用GridFS.作為替代,你可以存儲文件的多個版本,并且在元數據中指定文件的當前版本。在上傳新版本的文件后,你可以以原子更新來更新表示為"latest"的元數據字段,如果需要的話,你可以刪除以前的版本。

          For documents in a MongoDB collection, you should always use GridFS for storing files larger than 16 MB.

          In some situations, storing large files may be more efficient in a MongoDB database than on a system-level filesystem.

          • If your filesystem limits the number of files in a directory, you can use GridFS to store as many files as needed.
          • When you want to keep your files and metadata automatically synced and deployed across a number of systems and facilities. When usinggeographically distributed replica sets MongoDB can distribute files and their metadata automatically to a number of mongod instances and facilities.
          • When you want to access information from portions of large files without having to load whole files into memory, you can use GridFS to recall sections of files without reading the entire file into memory.

          Do not use GridFS if you need to update the content of the entire file atomically. As an alternative you can store multiple versions of each file and specify the current version of the file in the metadata. You can update the metadata field that indicates “latest” status in an atomic update after uploading the new version of the file, and later remove previous versions if needed.

          Furthermore, if your files are all smaller the 16 MB BSON Document Size limit, consider storing the file manually within a single document. You may use the BinData data type to store the binary data. See your drivers documentation for details on using BinData.

          For more information on GridFS, see GridFS.


          地址:http://docs.mongodb.org/manual/faq/developers/#faq-developers-when-to-use-gridfs

          posted on 2013-04-09 18:41 zhangxl 閱讀(510) 評論(0)  編輯  收藏 所屬分類: nosql
          <2013年4月>
          31123456
          78910111213
          14151617181920
          21222324252627
          2829301234
          567891011

          常用鏈接

          留言簿(1)

          隨筆分類(17)

          隨筆檔案(28)

          文章分類(30)

          文章檔案(30)

          相冊

          收藏夾(2)

          hibernate

          java基礎

          mysql

          xml

          關注

          壓力測試

          算法

          最新隨筆

          搜索

          •  

          積分與排名

          • 積分 - 96363
          • 排名 - 601

          最新評論

          閱讀排行榜

          評論排行榜

          主站蜘蛛池模板: 东辽县| 大关县| 纳雍县| 南京市| 霸州市| 山东省| 常宁市| 南宁市| 九龙城区| 新建县| 平昌县| 秦皇岛市| 张家口市| 白朗县| 桂东县| 孝昌县| 涟源市| 锡林郭勒盟| 卫辉市| 房山区| 彭水| 浦北县| 榆树市| 西平县| 贡山| 孟州市| 吴忠市| 鄂托克前旗| 弥勒县| 灵丘县| 广德县| 班戈县| 彭水| 彩票| 泰州市| 平度市| 安溪县| 本溪市| 综艺| 辛集市| 红河县|