【发布时间】:2013-06-29 11:40:45
【问题描述】:
我有一个 Python 脚本,它生成数据(每小时),供 PHP 网页稍后读取。我应该将数据存储在哪里——数据库、文件或其他地方?将有接近 100-200KB/用户的数据。哪个会是更好的解决方案?数据不是纯文本,这意味着我必须使用 json 或 xml 来存储它。
示例数据:(XML易读,别怪我!)
<item uid="1">
<title>Malala's voice stronger, not silenced</title>
<rating>3</rating>
<date>Wednesday, May 8, 2013 2:03 PM</date>
<text>The attack was meant to silence the outspoken teenager who dared to defy the Taliban's ban against girls in school. Instead, it only made Malala's voice more powerful. After a school year that started with a shooting, Malala now eyes a summer of speaking at the U.N., telling her story in a new book and amplifying the issue of girls education. </text>
</item>
【问题讨论】:
-
您可以发布您的数据的 sn-p 吗?以便我们知道您要存储什么样的数据?在某些情况下,文件可能是最好的,但在大多数情况下,数据库会做得最好。也许是一个组合?所以请给我们一些见解:)(如果它是一个很长的文本,用
(...)缩短它并告诉我们该列包含多少kb)。 -
我会在几秒钟内编辑它。
-
注意:你说你可以使用 json 或 xml。在考虑文件存储时也要考虑序列化数据。我注意到反序列化比解码 json 更快。但是编码 json 比序列化要快。我的观点是:你在哪里需要速度?写作还是阅读?
-
我在阅读时需要它,所以我可以将它序列化存储...所以是的...但是.. 数据库或文件?
-
我个人会选择数据库。只是因为访问方便。但是请查看the answer below。他有一个有效的观点。所以我想我在这里不会有太多帮助:)
标签: php python caching storage