我什么时候想使用文档数据存储以及何时使用键值数据存储?
谢谢!
没有明显的区别。
在键值存储中,您有一个对应于一组位的键(通常是字符串)。一个例子是 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: