我有一个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>
我认为这取决于您的web应用程序的规模。如果文件系统相当小,并且不会随时间增长那么大,那么文件系统就可以了。这是一个很好的选择,因为它很简单。非常容易读取/写入文件。你知道吗
如果您想要更重要的东西,可以使用分布式缓存,只在本地运行一个节点就可以启动它。你知道吗
有很多选择:
现在很多数据库都支持JSON:
我肯定会选择JSON作为您的序列化数据格式。你知道吗
一般来说,查询数据库是昂贵的,如果最终扩展应用程序,就会遇到问题,因为每次需要读取数据时,也需要查询数据库。这将导致读取数据失败。你知道吗
有一种方法可以避免这种情况。它叫做memcache。memcache的一个很好的介绍可以在第6课的Udacity course中找到。还有another post at stackoverflow解释了他们如何成功地与python和php语言共享memcache。你知道吗
相关问题 更多 >
编程相关推荐