I'm using mongodb for our web application.

Recently I'm think of adding redis for caching objects which usually is the setting/configuration. But the mongodb already cached the frequently accessed items.

So, do I need a redis for this use-case and why?

  • 1
    The question is. Do you even need cache? Moreover, you need it to be distributed? – Laiv Feb 14 '19 at 16:51
  • @Laiv: Thank Laiv for the response. To answer your first question, I need to measure our performance before and after apply the cache. Also, I need the cache to be distributed as currently I'm running 4 web nodes on our infrastructure – pcuong Feb 15 '19 at 3:11
  • 1
    The thing is, Mongodb and Redis will cache different things, at different points of the code and different moments in the request. Both are not mutually exclusive. Whether to use Redis or not is up to you to decide. We assume you have found a reason to implement it. A different question would be, how to make both to work alongside each other, accordingly with your needs. – Laiv Feb 15 '19 at 6:45

The difference between Mongo DB and Redis is that Redis is an in memory DB as opposed to Mongo DB, and in addition it is a key/value store which is very suitable for caching purposes.

In addition, if you handle the cache on your own, you have control over it, like when it expires and so on.

Laiv also made a right point and that is, do you need the cache to be distributed, because if not, then you can cache in memory which would give the fastest performance.

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.