开发者

What are the differences between MongoDB and Redis? [closed]

开发者 https://www.devze.com 2023-03-14 14:56 出处:网络
As it currently stands, this q开发者_开发百科uestion is not a good fit for our Q&A format. We expect answers to be supported by facts, references,or expertise, but this question will likely so
As it currently stands, this q开发者_开发百科uestion is not a good fit for our Q&A format. We expect answers to be supported by facts, references, or expertise, but this question will likely solicit debate, arguments, polling, or extended discussion. If you feel that this question can be improved and possibly reopened, visit the help center for guidance. Closed 10 years ago.

Just looking for what people see as the main differences when choosing between the two.


Data model

MongoDB

Document oriented, JSON-like. Each document has unique key within a collection. Documents are heterogenous.

Redis

Key-value, values are:

  • Lists of strings
  • Sets of strings (collections of non-repeating unsorted elements)
  • Sorted sets of strings (collections of non-repeating elements ordered by a floating-point number called score)
  • Hashes where keys are strings and values are either strings or integers

After Wikipedia.

Storage

MongoDB

Disk, memory-mapped files, index should fit in RAM.

Redis

Typically in-memory.

Querying

MongoDB

By key, by any value in document (indexing possible), Map/Reduce.

Redis

By key.


I just read a comparison between different NOSQL databases which I think sums it up pretty nicely:

MongoDB:

Best used: If you need dynamic queries. If you prefer to define indexes, not map/reduce functions. If you need good performance on a big DB. If you wanted CouchDB, but your data changes too much, filling up disks.

Redis:

Best used: For rapidly changing data with a foreseeable database size (should fit mostly in memory).


Redis is a key value store while mongofb is a document store.

Redis is awesome at storing unrelated pieces of information while mongodb is awesome at structuring or modeling information with relations between them.

I am not talking in absolute ways. They are both nosql databases and as such you can pretty much define the shape and colour of what you store but in practice, that is how they are usually used.

0

精彩评论

暂无评论...
验证码 换一张
取 消