loading...

re: How is usually consistency maintained between DB and cache? VIEW POST

FULL DISCUSSION
 

I would like either both of them to succeed or both of them to fail. How is this problem generally handled?

What do you mean?

I'd imagine the source of truth is MongoDB, and I'd imagine Redis is on top of MongoDB.

So, if the key has an expiration date, when it's expired you can ask MongoDB to give you the updated data.

During write you can write in MongoDB and invalidate the cached key so that the next read from Redis will fill the value from MongoDB.

Let me know if it makes sense or not :)

Code of Conduct Report abuse