Using mongo db as cache and database

Hi,

As, we have 2 types of storage engines in mongo db, in-memory, and wiredtiger-https://www.mongodb.com/docs/manual/core/storage-engines/,

  • What are the use cases of each
  • Can I use mix of these 2 engines in the same cluster or need a separate cluster for each type?
  • What’s persistence support for an in-memory storage engine and if I want to use it as a cache what caching mechanism it will leverage?

Hi @tukaram_bhosale & welcome!

I believe this reference should help you understand the use-case of an in-memory database: In-Memory Databases Explained | MongoDB
As a quick summary:

The main use case for in-memory databases is when real-time data is needed.

Before going further, I think it’s important to note the following:

If you are ready to give in-memory databases a try, you can give the in-memory storage engine with MongoDB Enterprise Advanced a spin or use MongoDB Atlas as a persistence layer alongside any other in-memory database.

Your need for the high performance (and cost) of an in-memory database may depend on your exact use case or requirements.

With regards to caching, you can explore using Redis for caching alongside MongoDB for persistence. Here’s a reference that compares between the two: MongoDB Vs. Redis Comparison: Pros And Cons | MongoDB

Thanks! So to confirm, we do not have a mixed mode available where I can have configurable in-memory caching as well as a persistence guarantee(something like Apache ignite provides).
Adding redis layer will add extra cost which I was looking to avoid.