“Redis for Caching and MongoDB for NoSQL, these are the de facto tech stacks come to our mind”
A database is called In-Memory when its data is stored fully or partially on system’s RAM instead of the harddisk. In general, the data is either on disk or on RAM, but keeping partial data on the RAM gives an edge to the existing database to retrieve records faster.
The ratio of data in-memory and data on disk depends on multiple factors. Redis and MongoDB both have the capability to store data partially in memory. Currently, I would like to share more generic info about these DBs and later I will write a different story on this topic.
Redis is widely used for caching, that supports key-value pair and offers various data structure like lists, strings, sets and more. Apart from caching, its use cases include pub-sub, realtime analytics and session management.
MongoDB is a popular NoSQL document based database that provides a flexible, high performance and scalable solution for storing and retrieving data. The documents are stored in JSON format rather than tables and columns in traditional RDBMS.
What if I tell you, there is a widely used database called Couchbase which is a hybrid of both Redis(In-Memory) and MongoDB(Document Based)!!! and more importantly, it is being used as primary database for enterprise grade applications.
Yes!! Couchbase is an open source In-Memory database and JSON based storage of documents.
When we have Redis and Mongo thats solves our purpose why do we even need another database.
First reason, it offers a RDBMS like querying feature called N1QL query (pronounced nickel query). With this unique capability, applications can retrieve data by writing SQL queries for the documents in collection. Since the data could be stored in-memory and with SQL like query feature, we would be able to fetch most accurate data in a fraction of seconds. This uniqueness makes couchbase stand out when compared with the other two.