Wednesday, 10 May 2017

Create a simple mutex with MongoDB

I just need a simple mutex, stored in MongoDB. I want a lock given a unique id. There seem to be many popular solutions with Redis, but in this case, since we are already using MongoDB, I am looking for some sort of library that I can use for locking with MongoDB, but I can't find any good packages. Is there a way to do a simple lock with Mongoose or the official MongoDB node.js driver?

I am especially looking for some mutex in MongoDB that was a built-in TTL. With Redis, you can give a key a TTL and it will remove itself after a period of time, that's an essential feature.

When I google "mongodb + ttl" this is what I see:

https://docs.mongodb.com/manual/core/index-ttl/



via Alexander Mills

No comments:

Post a Comment