MongoDB with redis

前端 未结 3 1189
情书的邮戳
情书的邮戳 2020-12-04 04:49

Can anyone give example use cases of when you would benefit from using Redis and MongoDB in conjunction with each other?

3条回答
  •  清歌不尽
    2020-12-04 05:22

    Obviously there are far more differences than this, but for an extremely high overview:

    For use-cases:

    • Redis is often used as a caching layer or shared whiteboard for distributed computation.
    • MongoDB is often used as a swap-out replacement for traditional SQL databases.

    Technically:

    • Redis is an in-memory db with disk persistence (the whole db needs to fit in RAM).
    • MongoDB is a disk-backed db which only needs enough RAM for the indexes.

    There is some overlap, but it is extremely common to use both. Here's why:

    • MongoDB can store more data cheaper.
    • Redis is faster for the entire dataset.
    • MongoDB's culture is "store it all, figure out access patterns later"
    • Redis's culture is "carefully consider how you'll access data, then store"
    • Both have open source tools that depend on them, many of which are used together.

    Redis can be used as a replacement for a traditional datastore, but it's most often used with another normal "long" data store, like Mongo, Postgresql, MySQL, etc.

提交回复
热议问题