0

我什么时候想使用文档数据存储以及何时使用键值数据存储

谢谢!

4

1 回答 1

0

没有明显的区别。

在键值存储中,您有一个对应于一组位的键(通常是字符串)。一个例子是 Memcached。您可以在“值”部分中放入任何内容:JSON 文档、序列化数据结构、压缩或加密文件等。一般来说,它只是位。

A document store, on the other hand, implies that you need to store data in a certain format. An example is MongoDB, which uses a binary version of JSON. The database might provide indexing by looking at the contents of the document, or might allow some form of querying. You get some extra features, but you're also constrained a bit by the format. For example, if you had a document store that worked with JSON, your data will likely take up way more space than if you stored a compact serialized format like Protobuf, and will be slower to parse.

Ultimately, those categories don't mean much. Every database technology is different, and each has pros and cons (though they'll all claim to be the best thing since sliced bread). Figure out what your needs are, and evaluate DBs based on that. Some things you may want to consider:

  • 你的数据是什么样的?你想怎么建模?
  • 你需要什么样的复制?一些 NoSQL DB 做主从,另一些有一个控制节点,还有一些是无共享的。
  • 他们是否有针对您计划编写代码的语言的 API?
  • 还有更多...
于 2012-09-07T15:23:52.880 回答