Reputation: 163
I have issues with mongoDB. Currently i'm working with Ruby mongodb drivers and there r some strange things r going on:
i need to insert 20 documents in the capped collection but when i write the following code, it inserts only 3 docs and i can't get what's going on:
coll = db.create_collection("test",:capped => true, :max=>20)
1024.times{@pad_string +=" "}
20.times{coll.insert({
:HostName => @hostname,
:CommandLine => @cmdline,
:Pid => "1111",
:BlockName => @blockname,
:ExitCode => 0,
:StartTime => Time.now,
:EndTime => Time.utc(2000,"jan",1,00,00,00),
:StdErr => @pad_string,
:Stdout => @pad_string}
)}
actually the point is that i insert @pad_string with 1024 preallocated spaces. As soon as i do that before inserting 1024.times{@pad_string +=" "}, it inserts only 3 docs maximum.
Upvotes: 1
Views: 840
Reputation: 3012
When you cap a collection based on the number of objects you also have to cap it based on size - I wonder what size the ruby driver is sending down.
try this:
coll = db.create_collection("test",:capped => true, :size=>100000, :max=>20)
Then tweak the size to whatever works for you (it's in bytes).
Upvotes: 2