Skip to content

Instantly share code, notes, and snippets.

@ttrelle
Created October 24, 2012 11:36
Show Gist options
  • Save ttrelle/3945598 to your computer and use it in GitHub Desktop.
Save ttrelle/3945598 to your computer and use it in GitHub Desktop.
Pessimistic Locking with MongoDB
db.workitem.lock.drop();
db.createCollection("workitem.lock");
db.workitem.lock.ensureIndex( { ts: 1 }, { expireAfterSeconds: 30 } );
db.workitem.lock.ensureIndex( { aid: 1 }, {unique: false} );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment