How do mongodb and nodejs do caching? ?

  node.js, question

Similar to the circle of friends, when a large number of users pull the feed, does it need a cache to store the latest data?

Should I choose Redis or Memcached?

If redis is selected, can it not be placed on the same server as mongodb?

“if you put MongoDB and Redis on the same box and MongoDB data do not fit in memory, MongoDB will “steal” memory to Redis via the OS paging mechanism. The consequence is a major performance drop for Redis.”

Cache inside Should Save What? Save all the original data? ? Or just store _id fields or something like that? ? … …

Since your back end uses node.js, mongoDB is your main database.
The structure of the data to be cached is more complex, using Redis.
If it is simple and has no special function, use Memcached.
However, I strongly recommend Redis.
Redis can be on the same server as your main database, or it can be different. This is up to you.
As for caching, of course you cache whatever you need. If you only cache _id, then you don’t need to query mongoDB.
For example, friends in your circle of friends all have comment names. Do you think that if you check the comment names according to your friend relationship, you can put this data in Redis and avoid checking it in the main database.