在MongoDB中使用悲觀鎖

jieforest發表於2012-10-25
In this article, I’m going to sketch a pattern for implementing pessimistic locking with MongoDB. MongoDB is a document-orientated NoSQL datastore that does not support locking itself.

In some business processes it may be required that you have an exclusive access to a single document. That’s when you need something like pessimistic locking.

Requirements

The implementation should offer the following features:

Locking does not change the locked document itself

Locks can be removed manually or by a timeout

For the rest of this article, let’s assume we want to lock documents in a collection called workitem.

來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/301743/viewspace-747237/,如需轉載,請註明出處,否則將追究法律責任。

相關文章