在本地存储 url 的最佳方式
我正在创建一个 RSS 阅读器作为一个业余爱好项目,并且用户可以添加自己的 URL。
我在想两件事。
- 一个纯文本文件,其中每个 url 都是单行
- SQLite,其中我可以在 URL 之后有唯一的 ID 和描述
SQLite 的想法是否需要很大的开销,或者是否有更好的方法来做这样的事情?
I am creating an RSS reader as a hobby project, and at the point where the user is adding his own URL's.
I was thinking of two things.
- A plaintext file where each url is a single line
- SQLite where i can have unique ID's and descriptions following the URL
Is the SQLite idea to much of an overhead or is there a better way to do things like this?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(5)
作为 OPML 文件怎么样? 它是 XML,因此如果您需要存储比 OPML 规范提供的更多数据,您可以随时添加自己的命名空间。
此外,从其他 RSS 阅读器的导入和导出都是通过 OPML 完成的。 通常有图书馆支持它。 如果您有兴趣让用户切换,那么您必须支持 OPML。 感谢詹姆斯提出这一点。
What about as an OPML file? It's XML, so if you needed to store more data then the OPML specification supplies, you can always add your own namespace.
Additionally, importing and exporting from other RSS readers is all done via OPML. Often there is library support for it. If you're interested in having users switch then you have to support OPML. Thansk to jamesh for bringing that point up.
为什么不使用 XML?
如果您正在处理 RSS,那么您也可以:)
Why not XML?
If you're dealing with RSS anyway you mayaswell :)
您打算只存储 URL 吗? 或者您计划添加诸如
last_fetch_time
之类的数据?如果它只是一个简单的 URL 列表,您的程序将逐行读取并下载数据,请将其存储在文件中,甚至更好地存储在写入文件的某些序列化对象中。
如果您打算扩展它,添加注释/上次获取的时间等,我会选择 SQLite,这并没有那么多开销。
Do you plan just to store URLs? Or you plan to add data like
last_fetch_time
or so?If it's just a simple URL list that your program will read line-by-line and download data, store it in a file or even better in some serialized object written to a file.
If you plan to extend it, add comments/time of last fetch, etc, I'd go for SQLite, it's not that much overhead.
如果它是只有一个实例的单用户应用程序,那么 SQLite 可能就有点大材小用了。
在我看来,你有几个选择:
If it's a single user application that only has one instance, SQLite might be overkill.
You've got a few options as I see it:
我会选择 XML 文本文件选项。 您可以使用 Visual Studio 中内置的 XSD 工具从 XML 数据创建 DataTable,并在需要时轻松序列回文件。
另一个需要注意的是,我确信您会希望最终用户能够对他们的 RSS 提要进行分类,并能够对它们进行潜在的搜索/排序,并且拥有这种数据表样式将对此有所帮助。
您将获得轻松的文件存储和访问,这是“数据库”结构的好处,但不完全是 SQLite 的开销。
I'd go with the XML text file option. You can use the XSD tool built into Visual Studio to create a DataTable out of the XML data, and it easily serializes back into the file when needed.
The other caveat is that I'm sure you're going to want the end user to be able to categorize their RSS feeds and be able to potentially search/sort them, and having that kind of datatable style will help with this.
You'll get easy file storage and access, the benefit of a "database" structure, but not quite the overhead of SQLite.