What are the differences between MongoDB and Redis?

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

Answers


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 sm 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.


Need Your Help

C++ Double Address Operator? (&&)

c++ stl operator-keyword memory-address

I am reading STL source codes and I have no idea what && address operator is supposed to do. Here is a code example from stl_vector.h.

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.