在 .Net 应用程序中保存/加载大量数据的最佳方法?
为 .Net 4.0 应用程序保存大量数据的最佳方法是什么?
现在我正在使用列表并序列化到“用户数据”文件夹中的文件,并且工作正常,但我想知道是否有更好/更快的方法来保存/加载大量数据。
我保存的数据仅包含大量单词,例如文档。
数据大小接近 1 MB。
What is the best way to save large amount of data for a .Net 4.0 application?
Right now I am using Lists and serializing to a file in "User Data" folder, and its working ok, but I want to know if there is a better/faster way of saving/loading large amount of data.
The data that I am saving contains only lots of words, like documents.
The size of the data is almost 1 mb.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
这实际上取决于您的应用程序的类型。我不会使用任何类型的 SQL 数据库来加载和保存不需要查询或转换的数据操作。将对象图映射到关系模型所需的时间根本不值得。
另外,由于与数据库(连接管理和映射)相关的开销,我不相信它会比简单的序列化更快。
我最近的经验是使用 BinnaryFormatter,它具有出色的结果(文件〜15mb)。更糟糕的是,你总是可以编写自己的格式化程序。
That really depends on the type of your application. I wouldn't use SQL database of any sort for to just load and save operation of data that I do not need to query or transform. The time it will take to map your object graph to a relational model just not worth it.
Also I don't believe it will ever be faster than simple serialization due to the overhead associated with databases (connection management and mapping)
My recent experience was with BinnaryFormatter which had excellent results (files ~ 15mb). Worse come to worse you can always write your own formatter.
有点取决于您的数据以及您如何将其存储在应用程序中。
但所有这些 NoSQL 存储系统都是可能的,或者只是将普通的二进制数据存入文件中。
Kinda depends on your data and how you have it stored in your app.
But all these NoSQL storage systems are a possibility or just plain binary data into a file.
当您说“大量数据”时,您到底是什么意思?一兆字节?太字节?
数据到底是什么?
如果它是一组帐户记录,它很可能属于某种数据库;如果它是一组图像或文字处理文档,则可能不会。
When you say "large amout [sic] of data", what exactly do you mean by that? A megabyte? a terabyte?
And what exactly is the data?
If it's a set of account records, it might well belong in a database of some sort; if it's a set of images or word processing documents, perhaps not.
如果您想要快速访问,一种方法是序列化为哈希表并缓存它。在读取和写入之间...
这里的问题当然是版本控制、命名空间的更改(然后您将无法反序列化...轻松)、死锁、并发等...
如果将文件保存为 XML 会更好/JSON,当您将其读入内存时,将其保存到哈希表中...以便快速访问...
If you want fast access, one approach would be to serialize to a hashtable, and cache it. In between reads and writes...
Problem here is ofcourse, versioning, changing of namespaces(then you wont be able to deserialize....easyly), deadlocks, concurrency etc....
Better if you save the file as a XML/JSON, and when you do read it in to memory save it into a hashtable...for fast access...