Skip to content

Instantly share code, notes, and snippets.

@daniel-roberts-10gen
Created April 2, 2012 11:15
Show Gist options
  • Save daniel-roberts-10gen/2282742 to your computer and use it in GitHub Desktop.
Save daniel-roberts-10gen/2282742 to your computer and use it in GitHub Desktop.
MongoDB Queuing Test
insertQ = function () {
for (i = 0; i < 1000; i++) {
db.queue.insert({message:"amessage", count:i, ts:new Date, status:"new"});
print("Count:" + i);
sleep(250);
}
}
dQueue = function() {
for(i=0;i<1000;i++) {
print("Messages in queue:"+db.queue.count({status:'new'}));
var msg = db.queue.findAndModify({query : {status:"new"}, update :{$set: {status:"inprogress"}}, new:true});
printjson(msg)
sleep(25);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment