Posted on June 6th, 2018 in Resources by Mr
Redis vs MongoDB

 

Redis is an in-memory database that has been benchmarked as the fastest database in the world, while MongoDB is known for its flexibility.

 

Who Uses These Databases?

Here are a few examples of companies that use these databases:

Redis: Jet.com, Samsung, Intuit, UnitedHealthcare, Shopify, TMZ

MongoDB: The Weather Channel, eBay, Electronic Arts, Forbes, Under Armour

What About Database Structure?

Redis: In its simplest form, Redis uses key-value stores to store data with pairs of a key and an associated value. This structure is very different from relational databases that have tables featuring rows and columns, and can be difficult for some traditional SQL buffs to master.

It is probably best to show how key-value works with an example:

Let’s assume you have a list of dog calendars and you need to track the photographer along with the type of dog for each calendar so you’ll know who to contact when you need a calendar for next year.

A simple key-value pair can be represented with this format:

Dogbreed : “beagle”

Photographer : “Joe Photographer”

To retrieve the dog breed or photographer from the example above, you would need to use the GET command:

> GET Dogbreed

“beagle”

> GET Photographer

“Joe Photographer”

When you need to retrieve additional dog breeds and photographers, one way to do this is to use namespaces. With namespaces, you add a unique number after the key name that will allow you to retrieve the data.

> GET Dogbreed:1

“beagle”

>GET Dogbreed:2

“labrador”

Redis also offers more advanced data structures like lists, sorted sets, hashes, strings, sets, bitmaps, and more. Redis Modules can be used to extend these capabilities further, turning it into a JSON store, search engine, rate limiter, and much more.

MongoDB: MongoDB uses JSON-like documents to store schema-free data. In MongoDB, collections of documents do not have to have a predefined structure and columns can vary for different documents.

MongoDB has many of the features of a relational database, including an expressive query language and strong consistency. However, since it is schema-free MongoDB allows you to create documents without having to create the structure for the document first.

 

 

 

推荐课程

6+X商业项目实战班
快速获得项目经验

6+X商业项目实战班

Web开发全栈项目班+1月实战
快速掌握面向工作的核心技术

Web开发全栈项目班+1月实战