Created
April 2, 2012 11:15
-
-
Save daniel-roberts-10gen/2282742 to your computer and use it in GitHub Desktop.
MongoDB Queuing Test
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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